SEO Page Generator Best Practices

When customizing your SuiteCommerce web store, it is important to consider the impact your changes may have on the SEO page generator. If the server-side rendering (SSR) malfunctions or fails entirely, partial content may be served to search engines, potentially harming your SEO. Therefore, when testing your changes, you should treat the SEO page generator as if it were another browser to test your changes in.

JavaScript Standards

The SEO page generator only supports JavaScript as defined in ECMAScript 5.1 (ES5.1):

  • In your extensions, do not use JavaScript standardized in newer versions, such as the let and const keywords or template literals.

  • When customizing the core code of a SuiteCommerce Advanced site built using 2019.2 or newer, you may use TypeScript and modern JavaScript, if it will use the standard transpilation process built into the developer tools that converts it to ES5.1.

  • If a third-party plugin or library uses JavaScript newer than ES5.1, it must be excluded from SSR using the methods detailed below.

Excluding Content from the SEO Page Generator

Remember that the role of the SEO page generator is to generate a version of a web page so that a search engine can crawl and index it. Accordingly, there may be customizations to your web store that are designed to enhance the experience of human users and are, therefore, irrelevant to web crawlers, such as a plugin that loads a chatbot to help answer your customers' questions. In some cases, these customizations may negatively affect web crawlers as they may interfere with the parsing of page content, lead to the indexing of unnecessary content, or use up crawling budget.

When this happens, it is recommended that you prevent this JavaScript from being included in the SSR process. To assist developers when they want to exclude content, there are utility functions included in the core code and extensibility API that can be used to enclose JavaScript that should not be rendered by the page generator.

The best practice, which is available when writing extensions and modern versions of SuiteCommerce Advanced, is to use a method on the Environment component.

            // Using the extensibility API (SuiteCommerce and SuiteCommerce Advanced Aconcagua (R2) or newer
// In an extension entry point file's mountToApp() function
 
var Environment = container.getComponent('Environment');
if (!Environment.isPageGenerator()) {
  // Code that won't run when being rendered on the server
} 

          

If you cannot use the extensibility API, you may use a utility function attached to the SC global variable.

            // A simple check
if (!SC.isPageGenerator()) {
  // Code that won't run when being rendered on the server
}
 
// Alternative function
if (SC.ENVIRONMENT.jsEnvironment === 'browser') {
  // Code that won't run when being rendered on the server
} 

          

Suggestions for Content to Exclude

The following is a list of things that may cause problems for SSR or may be unnecessary if included, and that you may want to exclude from the page generator.

  • JavaScript that was introduced in a version of ECMAScript newer than 5.1.

  • Plugins and libraries that do not benefit the page's content, such as chatbots, advertising, marketing, analytics, and so on.

  • jQuery plugins and methods that only provide UI benefits, for example those that might create transitions and animations.

  • Calls to web APIs that are used to provide new functionality to human users, such as the Geolocation API.

Limits

There are several governance limits that apply to any single page that has been sent for SSR, these include things like memory usage, CPU usage, and execution time. If execution of the page generator halts because of one of these limits, it typically indicates that you have faulty JavaScript that may be caused by recursion, forgotten timers, unresolved callbacks, excessive DOM querying, or recursion.

  • Generally speaking, a web page should load as fast as possible, but the page generator will time out after 20 seconds.

  • If the page generator fails to complete SSR, the generated content will be returned as is with a 206 (Partial Content) status code.

Related Topics

General Notices