Page Description in MetaData

Konry Lekreso asked on April 2, 2019 19:03

Hello,

I'm trying to set "Page Description" in Metadata to display same content which is pulled from SearchResults WebPart for all pages. Is there any way I can use it? {%HTMLHelper.HTMLEncode(TextHelper.LimitLength(HttpUtility.HtmlDecode(HTMLHelper.StripTags(CMS.Base.Web.UI.ControlsHelper.RemoveDynamicControls(DataHelper.GetNotEmpty(Eval("Content"), "")), false, true, " ", "@", "")), 160, ""))%}

Thanks

Correct Answer

Brenden Kehren answered on April 3, 2019 19:22

Then on the page your on, add a static text webpart to the template and set the value to be the macro of {%DocumentPageDescription%}. If you don't have any thing in that pages description field (meaning it's inheriting from the parent) then it will display nothing. For testing purposes, uncheck the inherit box and add something in the description field.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Rui Wang answered on April 2, 2019 20:10

Just a FYI, depending on what's included in the "Content", sometimes the first 160 characters may not make too much sense. For example, for some page types, the first 160 characters maybe a combination of text from first few fields.

Also, if the content editors are really that lazy to enter some nice and meaningful description for metadata, they should not use it. :)

1 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on April 2, 2019 22:53

You're talking about 2 different things Konry. "Content" from a Smart Search result is the value of the field you have marked as Content in the Page Type's Smart Search settings.

The metadata from a page is not the same. You can get the metadata by using a macro like so:

{%DocumentPageDescription%}
{%DocumentPageKeyWords%}
{%DocumentPageTitle%}

0 votesVote for this answer Mark as a Correct answer

Rui Wang answered on April 2, 2019 22:55

Brenden, I think he wants to automatically populate the metadata description using the first 160 characters like the search result teaser.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on April 2, 2019 22:58

That can be done with the macros I provided in a static text web part very easy Rui.

0 votesVote for this answer Mark as a Correct answer

Konry Lekreso answered on April 2, 2019 23:38 (last edited on April 2, 2019 23:40)

Brenden, the reason I was asking about Smart Search result is that when I use {%DocumentPageDescription%} it does not show me anything - there is no meta description at this point.. I figured that I'd like to use the same summary for Page Description which I'm currently using on Search Results page. Thanks

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on April 3, 2019 00:23

So where are you displaying this then? In a smart search result or on a page?

0 votesVote for this answer Mark as a Correct answer

Konry Lekreso answered on April 3, 2019 18:05 (last edited on December 10, 2019 02:31)

Brenden, you were right about {%DocumentPageDescription%} that it supposed to work.. but it doesn't show up at all. Although I'm able to use this macro to display og:description tag and it works.. any thoughts? Also, I was trying to use {%CurrentDocument.DocumentContent["editabletext"] |(identity)GlobalAdministrator%} which supposted to give me the content from webpart but it doesn't.. Thanks

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on April 3, 2019 19:12

You didn't answer my question:

Where are you displaying this then? In a smart search result or on a page?

0 votesVote for this answer Mark as a Correct answer

Konry Lekreso answered on April 3, 2019 19:17

Page

0 votesVote for this answer Mark as a Correct answer

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