Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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 snippet testing tool the JSON API returns book as a html link. However when I make the call in javascript the value of url is text("Read").

What am i missing ?

share|improve this question
    
"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 at 12:04

1 Answer 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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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