Adding H1 to the Title Tag

Miles Evans asked on July 20, 2017 04:45

I am tasked with doing the SEO for a large kentico 8.x install with around 3,000 pages. Having not even seen the Kentico backend yet I was wondering:

Q: Every page on our website has a descriptive H1 tag. Is there a macro/variable or method to add the H1 tag on specific pages into the title tags?

Same with the H2 tags! Otherwise I will have to do this by hand. Yikes!

Correct Answer

Brenden Kehren answered on July 20, 2017 20:51

I'd not set that in the page template, I'd set it in the actual page properties itself. You can set a macro in the page meta data properties without needing to modify your page template. In fact, you can do this on your master page and let it replicate through the other pages without an issue. What I'd do is set a default for your macro as well like:

{%H1FieldName|(default)DocumentName%}

This way if there is no H1FieldName it will auto populate with the Document's name vs. empty.

1 votesVote for this answer Unmark Correct answer

Recent Answers


Brenden Kehren answered on July 20, 2017 04:52

It would all depend on how your website is setup. If your H1 text is a field on a page type then you can use a macro in a webpart on possibly your master page.

If it's editable text on a page then it may be a bit more of a challenge since it isn't in structured content.

0 votesVote for this answer Mark as a Correct answer

Chetan Sharma answered on July 20, 2017 09:03

I agree to Brenden's answer that a lot will depend upon the structure of your website.

Since you're saying that every page has a descriptive H1 tag, one of the approaches could be to use Head HTML in your master template so that that web part can be managed from one place.

In the HTML section you can simply use <h1>{%H1FieldName%}</h1>

Similarly for H2 too. This is assuming that the descriptive H1 tag is part of you page type(s).

Tip :- In case you've multiple page types I would advise to keep field name common for all page types so that a common web part from the master page can work.

3 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on July 20, 2017 16:15 (last edited on December 10, 2019 02:31)

From SEO stand point page title has more weight than H1. Normally you do them the same. If all your page titles are ok you can do with macro <h1>{% CurrentDocument.DocumentPageTitle |(identity)GlobalAdministrator%}</h1> Like Brenden said it is all depends on your site set up. You have templates and master pages. May be just changing them will do 99% of you pages. Again it is all depends on your set up.

1 votesVote for this answer Mark as a Correct answer

Miles Evans answered on July 20, 2017 20:47

Thanks guys!

Keep in mind though I mean the Title tag requires the H1 value, so <title>{%H1FieldName%}</title>

Will that still work in the title tag? If that works it will save a ton of time, but if I understand correctly I need to make sure it is available as a 'page type' in my page template. I'll have to research that a bit further, thanks again guys.

0 votesVote for this answer Mark as a Correct answer

Miles Evans answered on July 21, 2017 22:22 (last edited on December 10, 2019 02:31)

Thanks very helpful Brenden =)

In fact, you can do this on your master page and let it replicate through the other pages without an issue.

Upon further inspection most <title> tags will be ok but I found ~5% will need to be tweaked manually, either because they're too long or not descriptive enough. I just want to confirm that the <title> can be overridden and adjusted on a page by page basis?

I also noticed that some groups of products or pages will require a different <title> tweak to include the parent category of the current page. After searching it looks like {% CurrentDocument.Parent.DocumentName |(identity)GlobalAdministrator%} will work for that? Hmm since the <title> is processed in the <head> tag will this data even be available when the page is rendering?

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on July 23, 2017 15:25

Yes you can override it on a page by page basis by unchecking three inherit box on the pages metadata properties.

Yes, you can use that macro for your page title without issue. The system does all the heavy page processing first then renders the page. During the rendering is when macros are processed.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.