1

I am trying to extract the book URL from a link using Microdata. The format is specified in Schema.org.

Here is my HTML:

<div class="col-sm-4 col-md-3" itemscope itemtype="http://schema.org/Book">
                <div class="thumbnail">
                    <img src="{{ book.thumbnailurl }}" itemprop="thumbnailUrl" style="width: 100px;height: 200px;">
                    <div class="caption">
                        <h4><span itemprop="name">{{ book.name }}</span> - <span itemprop="author">{{ book.author }}</span></h4>
                        <p><span itemprop="about"> {{ book.about }}</span></p>
                        <p> 

                                <a href="{{ book.url }}" itemprop="url" onclick="trackOutboundLink(‘{{ book.name }}’);">
                                  <button type="button" class="btn btn-default btn-md">
                                    <span class="glyphicon glyphicon-book"></span>Read
                                  </button>
                                </a>

                        </p>
                    </div>
                </div>
             </div>

When I use Google's snippet testing tool the JSON API returns book as an HTML link. However when I make the call in JavaScript the value of url is text("Read").

What am I missing?

  • 1
    "However when I make the call in javascript the value of url is text("Read")." - Can you show us a code for this? BTW: It probably belongs to stackoverflow. – MarcinWolny Jun 13 '14 at 12:04
1

Ok finally after a lot of digging, I have the answer.

The root cause is as follows: The Google CSE(Custom Search Engine) is not consuming the microdata property value as the href attribute of the "a" HTML element. It is consuming the child text content on the "a" HTML element.

The Google CSE is able to consume the href from a "link" HTML element.

Therefore.

 <a href="{{ book.url }}" itemprop="url" onclick="trackOutboundLink(‘{{ book.name }}’);">

will not work.

 <link itemprop="url" href="{{ book.url }}">
 <a href="{{ book.url }}" onclick="trackOutboundLink(‘{{ book.name }}’);">

works.

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.