How to define a canonical URL in SPSEOHeaderTagsArticleView and/or SPSEOHeaderTags

Johan van den H
Kilo Sage

A large number of our public knowledge articles are not being indexed by Google Search.
This was shown in the Google Search Console which we recently configured for our portal.

 

The main reason for not indexeing the knowledge articles is "Duplicate without user-selected canonical".
We have not set a Canonical URL for our instance so this might help in getting more of our public knowledge articles to get indexed and thereby findable on Google Search.

 

The ServiceNow documentation (Configure custom SEO tags for canonical URLs and localized knowledge articles) tells us to change the SPSEOHeaderTagsArticleView script it does not clearly tell what we should change to define the Canonical URL.

We also found that there is a option to set to determine if page should use a SEO script, but this seems not specifically for knowledge articles (see ServiceNow documentation: Enable SEO for localized versions of a portal page).
The documentation refers to the SPSEOHeaderTags script.

Can someone help us out what we should change and if the SPSEOHeaderTagsArticleView script is the only thing we need to change?

2 REPLIES 2

Matthew_13
Mega Sage

@Johan van den H - You’re definitely on the right track.

The duplicate without user-selected canonical message usually means Google sees multiple valid URLs for the same KB article and doesn’t know which one to index.

In ServiceNow I believe, SPSEOHeaderTagsArticleView is the key script for fixing this. That’s where you can define a single consistent canonical URL for knowledge article pages. The general SEO toggle and SPSEOHeaderTags won’t solve this by themselves from last go. Once the canonical is set consistently google indexing usually improves.

Thumbs up if this helps you. Thanks Kindly

Thank you @Matthew_13 

I agree that the solution is to configure the SPSEOHeaderTagsArticleView script, but we are not sure how to define the canonical URL there as the ServiceNow documentation is not very clear on how we should change the script.

Original SPSEOHeaderTagsArticleView script:

var SPSEOHeaderTagsArticleView = Class.create();
SPSEOHeaderTagsArticleView.prototype = Object.extendsObject(sn_km_portal.SPSEOHeaderTagsArticleViewSNC, {

    type: 'SPSEOHeaderTagsArticleView'
	
	/*
	
	generateSEOTags - The base function that calls all other functions. Returns array of objects in below format
	{
	   canonicalURL : 'https://instance.com/csp/?id=kb_article_view&sysparm_article=KB0000001',
	   hrefLangs : [{locale:'fr-ca', href: 'https://instance.com/csp?id=kb_article_view&sysparm_article=KB0000001'}],
	   customSEOTags : ['<meta custom-tag=""  property="og:title" content="Service Portal">']
	}

	generateCanonicalURL - returns fully qualified URL as string
	'https://instance.com/csp/?id=kb_article_view&sysparm_article=KB0000001'

	generateHrefLangArray - returns array of objects containing locale and href 
	[{locale:'fr-ca', href: 'https://instance.com/csp?id=kb_article_view&sysparm_article=KB0000001'}]

	generateCustomTagsForSEO - returns custom tags as array of strings that will be updated in the page dom as-is
	['<meta custom-tag=""  property="og:title" content="Service Portal">']
	
	*/
});


Our canonical URL should be defined as https://support.wur.nl

As an example here is a link to one of our public available knowledge articles: https://support.wur.nl/esc?id=kb_article&sysparm_article=KB0017030

Should we just replace "https://instance.com/csp" with "https://support.wur.nl/esc" in the script above?