Expand my Community achievements bar.

Is description meta tag generation buggy?

Avatar

Level 7

So, by default here's how CQ generates the description meta tag:

   <meta name="description" content="<%= xssAPI.encodeForHTMLAttr(properties.get("jcr:description", "")) %>"<%=xs%>>

This in turn converts all spaces to &#x20; 

Apparently search engines don't like this. Interestingly on Adobe's home page, the description content is not escaped so aggressively:

   <meta name="description" content="Adobe is changing the world through digital experiences. We help our customers create, deliver, and optimize content and applications.">

Has anybody else here had SEO issues with the out of the box meta description generation?

As far as I can tell, xssAPI.encodeForHTMLAttr is buggy, because there's no need to escape white space in an HTML attribute.

5 Replies

Avatar

Level 1

Did you manage to find a solution to this ? I have come across exact same issue in my code. And same issue with "keywords" field.

I am thinking using the encodeForHTML method instead , so the statement would change to :

   <meta name="description" content="<%= xssAPI.encodeForHTML(properties.get("jcr:description", "")) %>"<%=xs%>>

Does anyone else know if there is an issue with using encodeForHTML instead of encodeForHTMLAttr.  

  • Is it Good ?  Not so Good ? 

Reference - Line # 34, 35 of /libs/foundation/components/page/head.jsp

 

/Regards
Kanwal

Avatar

Level 10

Which AEM you are using? 

Can you use sightly with  @ context='html'

Avatar

Level 1

Should have mentioned.... cheeky

This is a CQ5.6 code written in jsp

Avatar

Employee

XSS-escaping is responsible for this.

Your statement: "Apparently search engines don't like this"

Do you have some more info on this?

Avatar

Level 4

In my case, SEO code is not getting right meta tags

 Any suggestion on how to fix this... Should I use encodeForHTML method instead ?