Based on a new requirements, we want to add a way for Content Editors to be able to specify the metadata SEO fields. I wanted to know if the following is a recommended way or if there is a better approach. We are using a solution based on https://github.com/sitecorelabs/xmcloud-foundation-head template.

I know there's this template /sitecore/templates/Feature/Experience Accelerator/SiteMetadata/_Seo Metadata that already has MetaKeywords and MetaDescription fields.

My idea was to add fields to this template and then add this to the base templates of the OOTB page template /sitecore/templates/Project/MySite/Page. This in order to add those fields to the content pages using this template (e.g. Home, About Us) and such.

Finally, I would modify the Next.js Layout.tsx component and update the Routefields default interface to include the new fields from SEO

interface RouteFields {
  [key: string]: unknown;
  Title?: Field;
   //new SEO fields

const Layout = ({ layoutData }: LayoutProps): JSX.Element => {
  const { route } = layoutData.sitecore;
  const fields = route?.fields as RouteFields;
  const isPageEditing = layoutData.sitecore.context.pageEditing;
  const mainClassPageEditing = isPageEditing ? 'editing-mode' : 'prod-mode';

  return (
      {/* <Scripts /> */}
        <title>{fields?.Title?.value?.toString() || 'Page'}</title>
        <link rel="icon" href={`${publicUrl}/favicon.ico`} />
        {/*Use new SEO fields here*/}

1 Answer 1


Speaking from experience on non-headless SXA: never change the default (feature or foundation) templates from SXA.

Create your own base template with your fields - add them to the same section if you want, that is possible. Add this base template to your site page template. Your editors will not notice the difference but this way you keep your changes nicely separated from the ootb templates.

And I'm no NextJS expert so if something is fishy there someone might elaborate on that - but normally you are completely free to create your head solution as you please.

  • Many thanks! The base template idea was just what I needed.
    – coolzoa
    Feb 18, 2023 at 0:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.