Site Initializer: Support SEO Settings for Pages

What is the problem you are trying to solve?

When building a site initializer, there is currently no way to configure advanced SEO settings for layout pages. The following SEO fields are completely unreachable from a site initializer:

  • Custom Canonical URL (customCanonicalURL_i18n)
  • HTML Title (htmlTitle_i18n)
  • Open Graph Title (openGraphTitle_i18n)
  • Open Graph Description (openGraphDescription_i18n)
  • Open Graph Image

What is your project about? (e. g. Intranet, Partner Portal, Enterprise Website, etc)

Enterprise Website.

What is your proposed solution?

Add an optional page-settings.json file alongside the existing page.json and page-definition.json in each layout directory:

  {
      "seoSettings": {
          "htmlTitle_i18n": { "en_US": "Home" },
          "description_i18n": { "en_US": "Welcome to My Site" },
          "seoKeywords_i18n": { "en_US": "home, portal" },
          "robots_i18n": { "en_US": "index, follow" },
          "customCanonicalURL_i18n": { "en_US": "https://mysite.com/home" }
      }
  }

BundleSiteInitializer._addOrUpdateLayout() should read page-settings.json when present and call LayoutSEOEntryLocalService.updateLayoutSEOEntry() so that SEO settings are applied programmatically during site initialization.