Getting the metadata of a page via expression

Kentico User asked on September 20, 2016 23:07


I am planning to use the following open graph meta tags and would like to use the description, title, and the current URL as a macro expression. I would like the description and the title to be the same as the description entered in the page metadata and I am hoping there is a way to find that using macros? The master page editor does not give an option to add a macros but I can use the "{% CurrentSiteName %}" so there must be a way to get description, title of the page and the URL.

Thank you,

Correct Answer

Jan Hermann answered on September 21, 2016 09:43

Roman's approach would work for you if you have all the titles and descriptions defined for all of your pages. If any page inherits page title form its parent, the macro would return null. pleas use following macros instead:

{% DocumentContext.CurrentDescription |(user)zbynekh|(hash)1637439e7b6c3ec684cfaeeadef685edabb00b2b1f3e19f0d5771a7cd79da14c%}
{% DocumentContext.CurrentTitle |(user)zbynekh|(hash)b1daac63486e81e2efe326e0c6d18fc94142c5243f9e59d52781907d6ea40172%}
1 votesVote for this answer Unmark Correct answer

Recent Answers

Roman Hutnyk answered on September 21, 2016 08:44 (last edited on March 24, 2018 12:15)

{% CurrentDocument.DocumentPageDescription |(user)zbynekh|(hash)ac96cb65c86ff27d893ead39efe7c2764c4f5b02de57b3c5bb07a7275a1461d4%} and {% CurrentDocument.DocumentPageTitle |(user)zbynekh|(hash)c0960da45ea99659cda4aacb386d686c24465b0a5aefb6dd500de0e21710a286%} should do that for you.

2 votesVote for this answer Mark as a Correct answer

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