4

I am in the process of installing Schema on my friends website. I'm adding ServiceType to his House Clearance page, as well as all his other services that he provides to the local area of Bournemouth using areaServed > GeoShape > circle, which is still in development.

Since the website is powered by WordPress the code within the loop looks like this:

<?php ?>
<?php while (have_posts()) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" itemscope itemtype="http://schema.org/Service">
    <?php the_title( '<h1>', '</h1>' ); ?>
    <?php the_content(); ?>
</article>
<?php endwhile; ?>
<?php get_footer(); ?>

WordPress the_ID

If your not familiar with WordPress id="post-<?php the_ID(); ?>" appends the unique page id to the element. As you can see from the code above both the id="post-X" and itemscope itemtype="http://schema.org/Service"are attached to the element container <article>.

Using Google's Rich Snippet Testing Tool I get the following results:

serviceType House Clearance

As you can see @id is taking the ID from the element and appending it to the path of the page without a HASHTAG, meaning that URL doesn't actually exist and returns a 404 status.

Question(s):

  • What is the purpose of Schema @id?
  • Does it matter if that URL is accessible or not?
  • Should I rename id="post-<?php the_ID(); ?>" to class="post-<?php the_ID(); ?>" or add a new line with serviceType?
5

I think this is a (long-standing) bug in Google’s SDTT.

Relevant Stack Overflow question:
Why does Google Testing Tool use the “id” attribute to generate a URL for the Microdata item?

In Microdata, only the itemid attribute should be able to give a URI for the item, while the id attribute is only used for referencing elements on the same page (with the itemref attribute), not for providing URIs. So the SDTT should never do anything with id values after following all itemref references.

If you provide a value for the itemid attribute, it overwrites the value the SDTT extracts from the id attribute. That would be the only way to fix this problem from our side.

<article id="post-29" itemscope itemtype="http://schema.org/Service" itemid="/acme-service#this">

The itemid attribute takes a URI as value. It’s a good practice to offer a relevant document under this URI, but it’s not required by Microdata. itemid serves the same purpose as @id in JSON-LD and resource in RDFa Lite.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.