How to auto generate introtext or description from content?

My client is too lazy or I say too dumb to write or copy paste meta description / introtext for seo.
He just want to write on content area. That’s it.
So im figuring out how to auto generate these tags for seo purpose and blog’s intro excerpt ?
Currently Im doing this but getting full content or if i modift tag then i get nothing.
I am doing something wrong but im unable to catch! Also please tell me how to strip words length.

[[+description:isnot=``:then=`[[+description]]`:else=`[[*content]]`]]

Thanks

Maybe you can use the output modifiers ellipsis or limit:

[[+content:ellipsis=`50`]]
[[+content:limit=`50`]]
3 Likes

Please also add htmlent as well as you otherwise risk breaking the entire page if the user enters double quotes.

And in the context of rendering a description for the current page (rather than a page being iterated over by get/pdoResources), you need to use * instead of + in the tags.

This example uses the full description, or the first 50 chars of the content, and encodes it with htmlent:

<meta 
    name="description" 
    content="[[*description:default=`[[*content:striptags:ellipsis=`50`]]`:htmlent]]"
>
2 Likes

This is what im looking for. Didnt know about htmlnet. Learned this new thing.
Thanks for helping. :slight_smile:

Also thanks to @halftrainedharry for the tip of limit… Much needed…

I am getting the description of Collection container’s description instead of its child’s which im fetching with following call -

[[!PdoResources?
    	&parents=`[[*id]]`
    	&tpl=`HdaLive_BlogRowTpl`
    	&includeTVs=`1`
    	&processTVs=`1`
    	&tvPrefix=``
    	&where=`[[!TaggerGetResourcesWhere]]`
    ]]

in HdaLive_BlogRowTpl

<p class="card-text">[[*content:striptags:ellipsis=`50`:htmlent]]</p>

Like I said:

As you mentioned it was for seo purposes I’d assumed the meta tag in the header, in which case you need to use * to get it for the current resource.

However, when listing child resources you need to use +. Resource fields vs placeholders.

For pdoResources to make [[+content]] available, you also need to add &includeContent=`1` to the snippet call. That’s ignored for performance reasons otherwise.

2 Likes

Thanks for the quickfix.
Working like charm.
Result here - https://hardalive47.com/

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.