Generate meta tag in header

Ashutosh Pandey asked on April 22, 2020 13:29

We are using Kentico 10. We need to have a meta tag generated in the head section like this:

<meta name="description" content="Some content go here"/>

We add new pages using page type Reports.

The page has a form with the field description. So, we need to show whatever we entered in description field into meta content.

Can I do it using a macro?

Should I enter that macro in Page -> Metadata -> Page description box?

Correct Answer

Ashutosh Pandey answered on April 25, 2020 11:21

I added Head Html web part and added following:

<meta name="description" content="{% CurrentDocument.GetValue("ShortAbstract") #%}"/>
0 votesVote for this answer Unmark Correct answer

Recent Answers


Peter Mogilnitski answered on April 22, 2020 16:21

You are pretty much answered your question yourself. Yes you can use macro in there.

0 votesVote for this answer Mark as a Correct answer

Ashutosh Pandey answered on April 22, 2020 18:48

Sorry Peter, may be I'm asking an already answered question but can you please tell which macro? I mean how can I access the page type data there?

0 votesVote for this answer Mark as a Correct answer

Dmitry Bastron answered on April 22, 2020 19:01 (last edited on April 22, 2020 19:02)

Hi Ashutosh,

Typically, this is a global header element, and you need to include the following meta tag in your Master Template's Header (find your master template in Templates application and open Header tab)

<meta name="description" content="{% Description %}"/>

This should give you an idea how to start, but basically you can write some logic in here using macros.

1 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on April 24, 2020 02:55 (last edited on April 24, 2020 02:55)

Page type should be {% CurrentDocument.ClassName #%}

0 votesVote for this answer Mark as a Correct answer

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