문제

I'm adding the schema.org Microdata to my website.

My HTML code is like this:

<div itemscope itemtype="http://schema.org/Organization">
<span class="title">Name of the organization</span>
<a href="http://www.ABCCompany.com/">ABC Company</a>
</div>

Since the itemprop "url" and "name" of the Organization are all in the anchor tag. How can I indicate the both "url" and "name" itemprop on the same tag? Must I add extra span tag for this purpose?

I have tried searching some coding examples on this but cannot find any example to show the use of multiple itemprop on the same tag.

At the end, I want to have Microdata like this:

url="http://www.ABCCompany.com", name="ABC Company"
도움이 되었습니까?

해결책

You have to do it by nesting two elements. For example, you can nest a <span> inside the <a> and put the itemprop="name" on that:

<div itemscope itemtype="http://schema.org/Organization">
    <a itemprop="url" href="http://www.ABCCompany.com/">
        <span itemprop="name">ABC Company</span>
    </a>
</div>

I find this site handy for testing such things.

다른 팁

There may be a problem with google. The "rich snippets testing tool" indicates that when you mark an anchor tag as a url, the body of the tag is used as value rather than the href attribute. But nobody wants to display the url inside an anchor tag.

This also works and may look a bit easier to maintain:

<div itemscope itemtype="http://schema.org/Organization">
<span class="title" itemprop="name"><a itemprop="url" href="http://www.ABCCompany.com/">ABC Company</span></a>
</div>

Google's support for schema.org and the google structured data tester have improved considerably since the original question was posted. The code above validates correctly in it.

The OP's original code now seems to work ok. As shown here:

https://search.google.com/structured-data/testing-tool#url=http%3A%2F%2Fmercedes-benzhanoi.com.vn%2Fmercedes-ha-noi.auto%2Fgla-250-4matic.html

<div itemscope="" itemtype="http://schema.org/Organization"> <span class="title" itemprop="name"> <a itemprop="url" href="http://mercedes-benzhanoi.com.vn/mercedes-ha-noi.auto/gla-250-4matic.html">GLA 250 4MATIC</a></span> </div>

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top