I'm new to bootstrap and trying to style the breadcrumb. I tried this and it gives me the proper inline layout I want.
<div class="BreadCrumbs">
<a href="www.yahoo.com" >Yahoo</a>
<span class="divider" > > </span>
<a href="www.example.com" >Example</a>
<span class="divider" > > </span> Google
</div>
But I want to add schema data and still maintain the proper styling. So I tried this but all the links are in different lines. How do I get them to be inline in one single line?
<div class = "BreadCrumbs" itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
<a href="www.yahoo.com" itemprop="url">
<span itemprop="title">Yahoo</span>
</a> ›
</div>
<div class = "BreadCrumbs" itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
<a href="www.example.com" itemprop="url">
<span itemprop="title">Example</span>
</a> ›
</div>
<div class = "BreadCrumbs" itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
<a href="www.google.com" itemprop="url">
<span itemprop="title">Google</span>
</a>
</div>
From Google: https://developers.google.com/search/docs/data-types/breadcrumbs
Use a list and then style the li elements inline
.breadcrumbs li {
display: inline;
}
<div class="breadcrumbs">
<ol itemscope itemtype="http://schema.org/BreadcrumbList">
<li itemprop="itemListElement" itemscope
itemtype="http://schema.org/ListItem">
<a itemscope itemtype="http://schema.org/Thing"
itemprop="item" href="https://example.com/books">
<span itemprop="name">Books</span>
<img itemprop="image" src="http://example.com/images/icon-bookicon.png" alt="Books"/></a>
<meta itemprop="position" content="1" />
</li>
›
<li itemprop="itemListElement" itemscope
itemtype="http://schema.org/ListItem">
<a itemscope itemtype="http://schema.org/Thing"
itemprop="item" href="https://example.com/books/sciencefiction">
<span itemprop="name">Science Fiction</span>
<img itemprop="image" src="http://example.com/images/icon-science-fiction.png" alt="Genre: Science Fiction"/></a>
<meta itemprop="position" content="2" />
</li>
›
<li itemprop="itemListElement" itemscope
itemtype="http://schema.org/ListItem">
<a itemscope itemtype="http://schema.org/Thing"
itemprop="item" href="https://example.com/books/sciencefiction/ancillaryjustice">
<span itemprop="name">Ancillary Justice</span>
<img itemprop="image" src="http://example.com/images/cover-ancillary-justice.png" alt="Ancillary Justice"/></a>
<meta itemprop="position" content="3" />
</li>
</ol>
</div>
Related
The correct inline implementation of breadcrumb should be something like this
<ol itemscope itemtype="http://schema.org/BreadcrumbList">
<li itemprop="itemListElement" itemscope
itemtype="http://schema.org/ListItem">
<a itemprop="item" href="https://example.com/dresses">
<span itemprop="name">Dresses</span></a>
<meta itemprop="position" content="1" />
</li>
<li itemprop="itemListElement" itemscope
itemtype="http://schema.org/ListItem">
<a itemprop="item" href="https://example.com/dresses/real">
<span itemprop="name">Real Dresses</span></a>
<meta itemprop="position" content="2" />
</li>
</ol>
but in my case I have a brand logo in first position and google complain for missing name
<ol itemscope itemtype="http://schema.org/BreadcrumbList">
<li itemprop="itemListElement" itemscope
itemtype="http://schema.org/ListItem">
<a itemprop="item" href="https://example.com/dresses">
<span itemprop="name"><img src="logo.svg" alt="Brand" width="56" height="60"></span></a>
<meta itemprop="position" content="1" />
</li>
<li itemprop="itemListElement" itemscope
itemtype="http://schema.org/ListItem">
<a itemprop="item" href="https://example.com/dresses/real">
<span itemprop="name">Real Dresses</span></a>
<meta itemprop="position" content="2" />
</li>
</ol>
Is it possible a correct inline code without adding a visible text?
looks like name is required in any case
try adding a name, and to the to meta tag, instead of span to avoid it being displayed
<ol itemscope itemtype="http://schema.org/BreadcrumbList">
<li itemprop="itemListElement" itemscope
itemtype="http://schema.org/ListItem">
<a itemprop="item" href="https://example.com/dresses">
<img src="logo.svg" alt="Brand" width="56" height="60"></a>
<meta itemprop="name" content="dresses" />
<meta itemprop="position" content="1" />
</li>
<li itemprop="itemListElement" itemscope
itemtype="http://schema.org/ListItem">
<a itemprop="item" href="https://example.com/dresses/real">
<span itemprop="name">Real Dresses</span></a>
<meta itemprop="position" content="2" />
</li>
</ol>
you could also use image license:
<ol itemscope itemtype="http://schema.org/BreadcrumbList">
<li itemprop="itemListElement" itemscope
itemtype="http://schema.org/ListItem">
<a itemprop="item" href="https://example.com/dresses" itemtype="http://schema.org/ImageObject" itemscope itemid="https://example.com/dresses" >
<link itemprop="contentUrl" href="https://example.com/logo.svg" />
<link itemprop="license" href="https://example.com/license" />
<link itemprop="acquireLicensePage" href="https://example.com/how-to-use-my-images" />
<img src="logo.svg" alt="Brand" width="56" height="60">
</a>
<meta itemprop="name" content="dresses" />
<meta itemprop="position" content="1" />
</li>
<li itemprop="itemListElement" itemscope
itemtype="http://schema.org/ListItem">
<a itemprop="item" href="https://example.com/dresses/real">
<span itemprop="name">Real Dresses</span></a>
<meta itemprop="position" content="2" />
</li>
</ol>
I am trying to utilize Microdata to help search engines define all the content of my website as it is intended to be viewed.
I have the following markup:
<!DOCTYPE html>
<html lang="en" dir="ltr" itemscope itemtype="http://schema.org/WebPage">
<head>
<link itemprop="url" href="https://example.com/link-to-canonical-url-of-this-page" />
</head>
<body>
<div itemprop="isPartOf" itemscope itemtype="https://schema.org/WebSite">
<link itemprop="url" href="https://example.com" />
</div>
<header itemscope itemtype="https://schema.org/WPHeader">
<ul class="list-unstyled mb-0 pb-0 mt-2" itemprop="citation" itemscope="" itemtype="http://www.schema.org/SiteNavigationElement">
<li>
<a title="" itemprop="url" href="/some-uri" class="btn btn-link text-white" style="font-size: larger;">
<strong itemprop="name">Popular Searches</strong>
</a>
<meta itemprop="position" content="1">
</li>
</ul>
</header>
<main role="main">
</main>
<footer itemscope itemtype="https://schema.org/WPFooter">
<ul class="list-unstyled mb-0 pb-0 mt-2" itemprop="citation" itemscope="" itemtype="http://www.schema.org/SiteNavigationElement">
<li>
<a title="" itemprop="url" href="/some-uri" class="btn btn-link text-white" style="font-size: larger;">
<strong itemprop="name">Popular Searches</strong>
</a>
<meta itemprop="position" content="1">
</li>
</ul>
</footer>
</body>
</html>
But when I view the above in Structured Data Testing Tool, it detects everything I intended except for the position of each element.
The tool detects the data as three different nodes. Since all these nodes are part of the WebSite or WebPage, I am hoping to somehow link the header and footer inside the WebPage node.
How can I indicate that the WPHeader and WPFooter are part of the WebPage node?
Update
I found a way to combine all 3 nodes into the main WebPage. However, I used multiple mainContentOfPage or mainEntity to do it. I am not sure if having mainContentOfPage is the correct way to do it. It kinds contradict the name as there should always be a main-content of a single page.
Here is the updated HTML markup:
<!DOCTYPE html>
<html lang="en" dir="ltr" itemscope itemtype="http://schema.org/WebPage">
<head>
<link itemprop="url" href="https://example.com/link-to-canonical-url-of-this-page" />
</head>
<body itemprop="mainContentOfPage">
<div itemprop="isPartOf" itemscope itemtype="https://schema.org/WebSite">
<link itemprop="url" href="https://example.com" />
</div>
<header itemprop="mainContentOfPage" itemscope itemtype="https://schema.org/WPHeader">
<ul class="list-unstyled mb-0 pb-0 mt-2" itemprop="mainEntity" itemscope="" itemtype="http://www.schema.org/SiteNavigationElement">
<li>
<a title="" itemprop="url" href="/some-uri" class="btn btn-link text-white" style="font-size: larger;">
<strong itemprop="name">Popular Searches</strong>
</a>
<meta itemprop="position" content="1">
</li>
</ul>
</header>
<main role="main">
</main>
<footer itemprop="mainContentOfPage" itemscope itemtype="https://schema.org/WPFooter">
<ul class="list-unstyled mb-0 pb-0 mt-2" itemprop="mainEntity" itemscope="" itemtype="http://www.schema.org/SiteNavigationElement">
<li>
<a title="" itemprop="url" href="/some-uri" class="btn btn-link text-white" style="font-size: larger;">
<strong itemprop="name">Popular Searches</strong>
</a>
<meta itemprop="position" content="1">
</li>
</ul>
</footer>
</body>
</html>
You can use the hasPart property.
<html itemscope itemtype="http://schema.org/WebPage">
<div itemprop="isPartOf" itemscope itemtype="http://schema.org/WebSite">
</div>
<header itemprop="hasPart" itemscope itemtype="http://schema.org/WPHeader">
<nav itemprop="hasPart" itemscope itemtype="http://schema.org/SiteNavigationElement">
</nav>
</header>
<main>
<article itemprop="mainEntity" itemscope itemtype="http://schema.org/CreativeWork">
</article>
</main>
<footer itemprop="hasPart" itemscope itemtype="http://schema.org/WPFooter">
<ul itemprop="hasPart" itemscope itemtype="http://schema.org/SiteNavigationElement">
</ul>
</footer>
</html>
I want to import only texts that contain only class="item-name"
Not and class="item-name active"
How do you think I could apply the import?
The HTML code is :
<li class="list-item" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
<a class="item" itemscope itemtype="http://schema.org/Thing" itemprop="item" href="/">
<span class="item-name" itemprop="name">Category</span>
</a>
</li>
<li class="list-item" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
<a class="item" itemscope itemtype="http://schema.org/Thing" itemprop="item" href="/outlet">
<span class="item-name" itemprop="name">Category 1</span>
</a>
</li>
<li class="list-item" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
<a class="item" itemscope itemtype="http://schema.org/Thing" itemprop="item" href="/outlet/fragrance">
<span class="item-name" itemprop="name">Category 2</span>
</a>
</li>
<li class="list-item" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
<span class="active-item" itemscope itemtype="http://schema.org/Thing" itemprop="item">
<span class="item-name active" itemprop="name">Title</span>
</span>
</li>
My php code :
if ($html !== false) {
$prod['id']=$html->find('span.code',0)->plaintext;
$j=0;
while (isset($html->find('span.item-name',$j)->plaintext)) {
$cats[]=str_replace(['.',';'],' ',html_entity_decode($html->find('span.item-name',$j)->plaintext));
$j++;
}
$prod['category']=implode(', ',$cats);
unset($cats);
}
UPDATE I fix
if ($html !== false) {
$prod['id']=$html->find('span.code',0)->plaintext;
$j=0;
while (isset($html->find('a.item',$j)->plaintext)) {
$cats[]=str_replace([' ',''',';'],' ',html_entity_decode($html->find('a.item',$j)->plaintext));
$new = preg_replace(['(\s+)u', '(^\s|\s$)u'], [' ', ''], $cats);
$j++;
}
$prod['category']=implode(', ',$new);
unset($new);
}
On researching how to do microdata for webpage breadcrumbs, I've found a couple of methods and I'm not sure which is correct. Firstly, my basic breadcrumbs in the HTML look like this:
<div>
Root page
Category page
This page
</div>
Now, do I structure it like this (as I've seen in an example on SchemaOrg:
<ol itemscope itemtype="http://schema.org/BreadcrumbList">
<li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
<a href="/" itemprop="item">
<span itemprop="name">Root page</span>
</a>
</li>
<li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
<a href="/category" itemprop="item">
<span itemprop="name">Category page</span>
</a>
</li>
<li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
<a href="/category/this-page" itemprop="item">
<span itemprop="name">This page</span>
</a>
</li>
</ol>
Or do I structure it like the below as I've seen in some Stackoverflow answers:
<div>
<span itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
<a href="/" itemprop="url">
<span itemprop="title">Root page</span>
</a>
</span>
<span itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
<a href="/category" itemprop="url">
<span itemprop="title">Category page</span>
</a>
</span>
<span itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
<a href="/category/this-page" itemprop="url">
<span itemprop="title">This page</span>
</a>
</span>
</div>
Or a different method I don't know about yet??
Modern (2019) correct breadcrumbs Microdata markup is like provided below.
And if you want to complain best practices do not make the last breadcrumb item as a link on your page - you can use <span> instead of <a> in a such manner:
<ol itemscope itemtype="http://schema.org/BreadcrumbList">
<li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
<a itemscope itemtype="http://schema.org/Thing" itemprop="item" href="/" itemid="/">
<span itemprop="name">Root page</span>
</a>
<meta itemprop="position" content="1" />
</li>
<li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
<a itemscope itemtype="http://schema.org/Thing" itemprop="item" href="/category" itemid="/category">
<span itemprop="name">Category page</span>
</a>
<meta itemprop="position" content="2" />
</li>
<li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
<span itemscope itemtype="http://schema.org/Thing" itemprop="item" itemid="/category/this-page">
<span itemprop="name">This page</span>
</span>
<meta itemprop="position" content="3" />
</li>
</ol>
This code is fully compliant to BreadcrumbList (see also that item's id is required) and passes Google validation on https://search.google.com/structured-data/testing-tool excellent.
I would do something like :
<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
<span itemprop="title">Homepage</span>
<div itemprop="child" itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
<span itemprop="title">Child-A</span>
</div>
<div itemprop="child" itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
<span itemprop="title">Child-B</span>
</div>
</div>
Tested on : https://search.google.com/structured-data/testing-tool
Use Schema.org as data-vocabulary.org is abandoned.
There were a few markups when the idea came up. But since then the standard has arrised as being Schema.org. It's of course supported by Google and given in its examples (one is BreadCrumbs).
The second is not part of schema.org, it uses a different vocabulary from data-vocabulary so I can't comment on if it works. The first is microdata using schema.org, which is the type given in google's breadcrumb examples.
Only structured data including Schema.org links uses schema.org - but you can use <div> and <span> with Schema.org if you want to. Structured data gives the meaning of the page and should for the most part be independent to how it appears visually, meaning that it doesn't matter whether you use bullet points or <div>s for your breadcrumbs, the structured data will work in the same way for both and have the same meaning.
It might be a subjective decision to be made. I would prefer Microdata method from Google as shown at https://developers.google.com/structured-data/breadcrumbs which follows ol/li method.
As long as you mention itemscope, itemptype and itemprop properly, it should't matter much which method you use.
you need to use "name" not "title", read all about it on in the docs: https://developers.google.com/search/docs/data-types/breadcrumbs
<ol itemscope itemtype="http://schema.org/BreadcrumbList">
<li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
<a itemtype="http://schema.org/Thing" itemprop="item" class="" href="https://exampe.com/">
<span itemprop="name">Root page</span></a>
<meta itemprop="position" content="1">
</li>
<li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
<a itemtype="http://schema.org/Thing" itemprop="item" class="" href="https://exampe.com/category">
<span itemprop="name">Category page</span></a>
<meta itemprop="position" content="2">
</li>
<li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
<a itemtype="http://schema.org/Thing" itemprop="item" class="" href="https://exampe.com/category/this-page">
<span itemprop="name">This page</span></a>
<meta itemprop="position" content="3">
</li>
</ol>
To fix Fix Breadcrumbs markup in Google Search Console about missing field "id" , I just removed property itemscope from anchor
from
<a itemscope itemtype="http://schema.org/Thing" itemprop="item" href="..">link</a>
to
<a itemtype="http://schema.org/Thing" itemprop="item" href="..">
and it worked. I tested and checked this on 2 websites that I got that error.
I have currently implemented my breadcrumbs like this:
<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
<a href="HOME URL" itemprop="url">
<span itemprop="title">HOME TITLE</span>
</a> >
</div>
<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
<a href="1ST LEVEL URL" itemprop="url">
<span itemprop="title">1ST LEVEL TITLE</span>
</a> >
</div>
<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
<span itemprop="title">CURRENT TITLE</span>
</div>
As you can see, I haven't specified a url for the current page, which would be redundant.
But when I try the Google testing tool, I get an error saying that the url is missing for the current page breadcrumb.
Given that, I have three options that I can think of.
I specify a url for the current page:
<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
<a href="HOME URL" itemprop="url">
<span itemprop="title">HOME TITLE</span>
</a> >
</div>
<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
<a href="1ST LEVEL URL" itemprop="url">
<span itemprop="title">1ST LEVEL TITLE</span>
</a> >
</div>
<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
<a href="CURRENT LEVEL URL" itemprop="url">
<span itemprop="title">CURRENT TITLE</span>
</a>
</div>
I just display the current page title without including it in the structured data markings:
<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
<a href="HOME URL" itemprop="url">
<span itemprop="title">HOME TITLE</span>
</a> >
</div>
<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
<a href="1ST LEVEL URL" itemprop="url">
<span itemprop="title">1ST LEVEL TITLE</span>
</a> >
</div>
<span>CURRENT TITLE</span>
I don't display the current level in the breadcrumbs (I don't want to do that I must say):
<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
<a href="HOME URL" itemprop="url">
<span itemprop="title">HOME TITLE</span>
</a> >
</div>
<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
<a href="1ST LEVEL URL" itemprop="url">
<span itemprop="title">1ST LEVEL TITLE</span>
</a>
</div>
What do you think it's best I should do?
The solution is to use the <meta> tag.
So, the last item in your breadcrumb should look like this:
<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
<span itemprop="title">CURRENT TITLE</span>
<meta itemprop="url" content="CURRENT URL" />
</div>
This will validate on the Google testing tool and achieve your desired goal to construct a valid breadcrumb without "displaying" a redundant link.
For reference: Getting started with schema.org using Microdata
3c. Missing/implicit information: use the meta tag with content
Sometimes, a web page has information that would be valuable to mark
up, but the information can't be marked up because of the way it
appears on the page... In these cases, use the meta tag along with the content attribute to
specify the information.
Have to add that for sake of completeness that to have a properly formatted breadcrumb for Google SERP, according to their current specs, your example code should look like this:
<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb" id="a" itemref="b">
<a href="HOME URL" itemprop="url">
<span itemprop="title">HOME TITLE</span>
</a>
</div>
<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb" id="b" itemprop="child" itemref="c">
<a href="1ST LEVEL URL" itemprop="url">
<span itemprop="title">1ST LEVEL TITLE</span>
</a>
</div>
<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb" id="c" itemprop="child">
<span itemprop="title">CURRENT TITLE</span>
<meta itemprop="url" content="CURRENT URL" />
</div>
Bear also in mind that the Google breadcrumb documentation is due for review shortly, since it seems that, at last, Google has adopted the schema.org markup for breadcrumbs from what can be inferred from the "Better presentation of URLs in search results" post in the Official Google Webmaster Central Blog and discussion on it.
I would go with the option of just showing the title, current level not included in the markup as below. IMHO you don't have to include the current page in breadcrumb, as the SERP will anyway point to the current page. It makes sense to provide breadcrumb from one level higher than the current page. hope this helps. BTW, we have done it that in our organization.
<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
<a href="HOME URL" itemprop="url">
<span itemprop="title">HOME TITLE</span>
</a> >
</div>
<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
<a href="1ST LEVEL URL" itemprop="url">
<span itemprop="title">1ST LEVEL TITLE</span>
</a> >
</div>
<span>CURRENT TITLE</span>