Search code examples
jspschema.orgrich-snippets

Rich snippet tags itemscope and itemtype has fixed order, how to generate that in JSP?


Trying to add rich snippets to a JSP-generated page. Spent a few hours on it with no luck and then realized that the generated page looks like this:

 <p itemtype="http://schema.org/LocalBusiness" itemscope="itemscope">

This is not recognized by the Google rich snippet test tool. If I move the itemscope tag before itemtype, it works.

What can I do about this? The parser reads my JSPX and spits it out with the tags in arbitrary order. Can I have control over the tag order somehow?


Solution

  • Not the nicest solution but if Google won't follow standards, who am I to argue...

    In the JSPX file, I generate the HTML like this:

    &lt;p itemscope="itemscope" itemtype="http://schema.org/LocalBusiness"&gt;
    ...
    &lt;/p&gt;