Modify the Title Server Side

Shawn Dowler
Tera Guru

Is it possible to modify the title attribute of a page server-side? We would like to open up some of our Knowledge Base articles to Google and the only way I know to modify the title of a ServiceNow page is using client side javascript and setting top.document.title dynamically. Does this work to change the title that Google displays in search results? If not, is there a better way? Erich Zirnhelt mentions in his blog post Enhancing KB Articles with metadata for SEO and Social Sharing that ServiceNow modifies the title on every Knowledge Base page and that Google uses the title in the search results, so this must be possible. Thanks for any ideas.

1 ACCEPTED SOLUTION

For everyone's benefit, here is the answer from Michael Wimble:



If you create a UI Macro with the name 'html_page_title', you can dynamically create on the server side the title for the page. The macro should ultimately produce the '<title>blah blah</title>' element.



If you try this client-side, search engines are not going to execute any Javascript, and will only see the raw form of the page.



I will try this and report back.


View solution in original post

5 REPLIES 5

lawrence_eng
Administrator
Administrator

Hi Shawn,



For better visibility, I moved your question to the Implement sub-community (and out of Community Updates & Feedback ).



Thanks,


Lawrence


michael_wimble
Kilo Contributor

I mentioned a solution in Erich's article.


For everyone's benefit, here is the answer from Michael Wimble:



If you create a UI Macro with the name 'html_page_title', you can dynamically create on the server side the title for the page. The macro should ultimately produce the '<title>blah blah</title>' element.



If you try this client-side, search engines are not going to execute any Javascript, and will only see the raw form of the page.



I will try this and report back.


Michael Wimble: I am having difficulty accessing the title of the KBA from the UI Macro. I have tried various ways including using RP.getParameterValue('sys_kb_id') but I found out that RP is not Defined in UI Macro. I tried looking to the kb_view UI Page for hints, but it's mostly references to xml files that I can't get to from the ServiceNow UI. So now I'm hoping you could at least provide a proof of concept example for grabbing the article title from the html_page_title UI Macro. Bonus points if it can also distinguish between page types and display something generic for anything that's not a KB Article.