I’ve run into a problem with my meta descriptions. This is what I would normally use:
<meta name="description" content="[[*description:empty=`[[*content:striptags:strip:esc:ellipsis=`155`]]`:striptags:strip:esc:ellipsis=`155`]]" />
It works fine in most cases, but now I’ve run into a case where tags aren’t stripped from the content field. I believe it’s caused by the content field starting with a chunk which contains tags.
To simplify things I’ve narrowed it down to this call, which it turns out doesn’t strip tags which are in the chunk:
I’ve also tried [[!*content:striptags]] and [[*content:notags]] and get the same results – tags are still rendered in the output.
Are there any workarounds for this, except moving the chunk html to the content field (which I would prefer to avoid as the same code is used in a number of pages)?
Using MODX Revolution 2.7.2.
@sketchi, welcome to the community!
Well, while that seems to be a real problem (I’ll wait for modx board members to comment), I think that working SEO that way can be problematic and play against your site.
Is there any specific reason for you wanting the meta description tag that way?
Have you tried SEOpro?
I think this will work better for SEO
Is the chunk tag called uncached (with the !)? That could delay the processing of the chunk until after the filter has run, making it impossible for the tags to be stripped.
Hi guys, sorry for not feeding back sooner. I assumed I’d be notified by email since I’m “watching” the post but I didn’t.
@jnogueira, thanks! In what way would it be problematic to fall back to the page content if the description field is empty? Is it better for the meta description to be blank? Please explain!
@bobray, no, the chunk is called cached, like this: [[$chunkname]]. Any other ideas?
Well, regarding SEO best practices, Meta description is not even to be considered / used, but the truth is that it is still considered by some search engines (and we tend to optimize it only for Google and apparently google discarded this meta tag on its own indexing methodology).
The best practices state that META description should be short and self-descriptive (per each page) for obvious reasons, as will help to pull-up the results ranking.
If this is not that important for you, then you can go ahead using content field.
While you already have a whole bunch of tags in there… there’s a new
stripmodxtags output filter added in I believe 2.7 that can serve to remove MODX tags from the output. Use that to filter out the chunk tag from the content.
You wont get the contents that are in the chunk as part of your description, but that’s probably okay.
Added to docs.)
@markh, that’s very handy and solves the problem in this particular case at least. It would be great if it could be added to this page too
Off topic, is there any way to be notified by email when there’s a new reply to a post in this forum?
I’ve only added it to the new docs and don’t immediately plan to backport all changes to the older ones
The old ones will be replaced at some not-yet-determined point in the future anyway.
Watching the topic should be enough (I just got an email about your reply), but perhaps you need to check your email preferences. Click your avatar in the top right > preferences > emails/
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.