The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Lokenath Chakra
ServiceNow Employee
ServiceNow Employee

Google and other Search engine crawlers find it difficult to process JavaScript. Since most modern websites are based on JavaScript, including ServiceNow Portal pages, this means crawling and indexing content on a public portal page can be unsuccessful or slow. This may lead to an incomplete page being indexed on public search engines. 

To avoid this, dynamic rendering can be used to detect search engine crawlers and serve content suited for the crawler, which is often static HTML. This is already implemented out of the box in San Diego for kb_search and kb_article_view pages through the Script Includes SPSEOHeaderTagsArticleSearchSNC and SPSEOHeaderTagsArticleViewSNC respectively. Any other portal that uses the kb_article_view page for displaying articles will also get dynamic rendering for their public articles automatically with San Diego.

To implement Dynamic Rendering on other Portal pages in ServiceNow, a System Administrator can perform the following steps to render a raw HTML version of the page to crawlers. The HTML page is crawled faster and leads to better SEO (Search Engine Optimization) for the public page. 

Role required: System Administrator. 

Supported versions: San Diego and higher versions. 

  1. Create a new Script Include SPSEOHeaderTagsCust. 
  2. Paste the following code in the script editor:
  3. var SPSEOHeaderTagsCust = Class.create(); 
    
    SPSEOHeaderTagsCust.prototype = Object.extendsObject(global.SPSEOHeaderTags, { 
    
     
    
    generateSEOHTML: function(){ 
    
    //Add your page content here 
    
    return 'Page HTML content'; 
    
    }, 
    
     
    
    type: 'SPSEOHeaderTagsCust' 
    
    }); 
  4. Edit the generateSEOHTML function to return the HTML content from the page that you want to return. 
  5. As an example, you can refer to script includes SPSEOHeaderTagsArticleSearchSNC and SPSEOHeaderTagsArticleViewSNC that are used to generate HTML content for kb_search and kb_article_view pages, respectively. (These script-includes are available in San Diego version or later). 
  6. In your instance, navigate to Service Portal -> Pages. 
  7. Open the page which needs to be pre-rendered. 
  8. Note: Since SEO is only relevant for public pages, the Public checkbox should be checked for this page. 
  9. Check the checkbox Use SEO Script, if not already checked. 
  10. In SEO Script field, search and select SPSEOHeaderTagsCust
  11. Save the changes.

Testing the pre-rendered HTML version of a page: 

After doing the above changes, you can test how your page will be presented to Googlebot by following these steps:

  1. Open the public page as a guest (not logged in) user in Chrome. 
  2. Right click on the page and select Inspect, which opens Chrome DevTools. 
  3. Keep Chrome DevTools open during the testing. 
  4. Change the User Agent to “Googlebot Smartphone” by following the steps in https://developer.chrome.com/docs/devtools/device-mode/override-user-agent/  
  5. Refresh the page to test how the page will be rendered when Googlebot is trying to crawl the page. 
4 Comments