A lot of blogs refer to
And the original idea is based on
Thank you, Hoktro-san, Aneesh-san. It’s still useful but has the following issues at present.
- The structured data type definition is based on the obsolete Data-Vocabulary.org, not schema.org.
- Not using ordered list (
<ol>
<li>
), commonly used for breadcrumbs.
I try to modify these issues.
FYI
1. Add <b:includable>
The modified code snippet of <b:includable>
is as follows.
It uses RDFa as a structured data format.
<b:includable id='breadcrumb' var='posts'>
<!-- breadcrumb start -->
<ol id='breadcrumb' typeof='BreadcrumbList' vocab='http://schema.org/'>
<b:if cond='data:blog.homepageUrl != data:blog.url'>
<li property='itemListElement' typeof='ListItem'>
<a expr:href='data:blog.homepageUrl' property='item' typeof='WebPage'>
<span property='name'>Home</span></a>
<meta content='1' property='position'/>
</li>
<b:if cond='data:blog.pageType == "static_page"'>
<li><data:blog.pageName/></li>
<b:else/>
<b:if cond='data:blog.pageType == "item"'>
<!-- breadcrumb for the post page -->
<b:loop values='data:posts' var='post'>
<b:if cond='data:post.labels'>
<b:loop index='index' values='data:post.labels' var='label'>
<!-- b:if cond='data:label.isLast == "true"' -->
<li property='itemListElement' typeof='ListItem'>
<a expr:href='data:label.url' property='item' typeof='WebPage'>
<span property='name'><data:label.name/></span></a>
<meta expr:content='data:index + 2' property='position'/>
</li>
<!-- /b:if -->
</b:loop>
<li><data:post.title/></li>
<b:else/>
<li>Unlabelled</li>
</b:if>
</b:loop>
<b:else/>
<b:if cond='data:blog.pageType == "archive"'>
<!-- breadcrumb for the label archive page and search pages.. -->
<li>Archives for <data:blog.pageName/></li>
<b:else/>
<b:if cond='data:blog.pageType == "index"'>
<b:if cond='data:blog.pageName == ""'>
<li>All posts</li>
<b:else/>
<li>Posts filed under <data:blog.pageName/></li>
</b:if>
</b:if>
</b:if>
</b:if>
</b:if>
</b:if>
</ol>
<!-- breadcrumb end -->
</b:includable>
Insert this snippet before <b:includable id='main' var='top'>
in Edit HTML.
* I recommend the backup before editing.
Note:
After saving it, the formatter of Edit HTML moves the snippet, as snippets are in an alphabetical order of id
, and indent the first line of the snippet.
- If you comment out
<b:if cond='data:blog.homepageUrl != data:blog.url'>
and end-tag</b:div>
, you can display the breadcrumb trail at all times including top page. - If you comment in
<!-- b:if cond='data:label.isLast == "true"' -->
and<!-- /b:if -->
, the breadcrumbs include only the last label (in alphabetical order).
(When you use more than one label, labels are sorted forcibly in alphabetical order.)
Usage of Search Function in Edit HTML
In Edit HTML, press Ctrl
+ F
keys, then search box is displayed in upper right corner.
Input the search string and press Enter
key. Each time press Enter
key, the cursor jumps to the next match.
2. Add <b:include>
Next, insert the following widget tag for display before the part of <b:include data='top' name='status-message'/>
.
<b:include data='posts' name='breadcrumb'/>
- If you put it just before
</div>
corresponding to<div class='blog-posts hfeed'>
, the breadcrumb list is placed at the bottom of the page. - If you put it before
<b:if cond='!data:mobile'>
, the breadcrumb list can be shown in mobile pages as well.
3. Add CSS
Finally, add CSS as follows. Please modify as needed.
/* breadcrumb */
ol#breadcrumb{
font-size:13px;
padding: 8px;
}
#breadcrumb li {
display: inline;
list-style-type: none;
}
#breadcrumb li:after {
content: " > ";
}
#breadcrumb li:last-child:after {
content: none;
}
It’s all done.
Structured Data Testing Tool
You can check whether the breadcrumb list is working properly with Google Structured Data Testing Tool.
You must input URLs showing breadcrumbs.
You may find some errors in BlogPosting (not breadCrumbList).
You don’t have to care about it unless you want to reflect these error items correctly to search results. See Structured Data testing Tool errors on Blogpost Blogger - Google Product Forum.
If you want to fix them, this site may help you.
Remaining issue
Breadcrumbs are listed in alphabetical order, not showing the actual hierarchy.
To be continued in Blogger: Sort Breadcrumbs by Label Frequency.
Hi! I am trying to implement this on my blog, but I don´t want that all the labels on the post appear on the breadcrumbs. How can I just put 3 labels on it? Thanks!
ReplyDeleteHi, Angélica. You can find <!-- b:if cond='data:label.isLast == "true"' --> in 18th line. Please replace it with <b:if cond='data:index < 3'>. And replace <!-- /b:if --> in 24th line with </b:if>. Then 3 labels are displayed at most.(Note they are in alphabetical order.) Thanks.
DeleteHi nkuri! I made those changes, but all the labels are still displaying...Thanks!
DeleteHi, thanks for trying. I tried it in my own pages and confirmed it worked fine. Let me make sure about "3 labels". Breadcrumbs such as "Home > labelA > labelB > labelC > labelD > PostTitle" have 4 labels. You want to omit "labelD". Is it right?
Deletenkuri yes, I want to omit labelD. I misunderstood the way the trail is made, so I change the number like this and it works fine! (Home + 2 labels)
ReplyDeleteI just didn't want the breadcrumbs so long because in some post I have 5 labels or so...
I was trying to paste the code here but could't, haha!
Thank you very much for your help, very kind from your part!
Glad to hear that!
DeleteHello and thanx for the tutorial,it works.I tried adding up a custom CSS to it and it's looking messed up with three ">" coming in between out of nowhere,can you please take a look at this post-->https://thatswhtilike.blogspot.com/2018/06/hellequin-chronicles-series-books-1.html or any. Thank You!
DeleteGreat work Nkuri. Keep it up.
ReplyDeletewhere will i put CSS code
ReplyDeleteHi, Ismail. Please use a standard way of adding CSS on blogger, you can search online.
Deletegreat , it's work for me fine , but I got this error at home page
ReplyDelete@type
BreadcrumbList
itemListElement
Veuillez saisir une valeur pour le champ itemListElement
--- any help thanks Nkuri ---
I hope this page will be of some help.
Deletehttps://support.bigcommerce.com/s/question/0D54O000065iTY0SAM/alert-a-value-for-the-itemlistelement-field-is-required
Thank you very much Nkuri.
DeletePlease i need video to make this changes
ReplyDeleteSorry, I've no plans.
ReplyDeleteHi, does this still works in 2020? I'm a real newbie on schema.org.
ReplyDeleteYes, I use RDFa, which is supported by Gooogle search. FYI: https://developers.google.com/search/docs/guides/intro-structured-data#structured-data-format
Deletehello, your code is working fine but it is showing error for homepage.
ReplyDeleteplease validate your site's homepage schema.
Yes, I've found my top page has some errors in breadcrubmList by Google
Deletetesting tool. These errors seem to be irrelevant to breadcrumbList.
When I pushed VALIDATE button again (after adding a space in the left pain), the errors disappered. I don't think that is good. It may be better off not putting breadcrumbs on top page. Let me think. Thank you for your information.
Can you share latest updates for SEO Services?
ReplyDeleteFor my main page it is not showing any structured data but for individual pages it is showing. Any idea what is going wrong with my website?
ReplyDeleteSorry for the late reply.
ReplyDeleteDid you use Google Rich Result Test? https://search.google.com/test/rich-results
(Structured Data Testing Tool is obsolete.)
And can't you find any "Breadcrumbs" in the test result?
Could you confirm "" and "" were commented out, as the notes of this post?
This is my first time i visit here. I found so many interesting stuff in your blog especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here keep up the good work palottery
ReplyDeleteThanks for the information, very useful!
ReplyDelete
ReplyDeleteHi, I don't know why but with all the tutorials I've tried (including yours) the "breadcrumbs" always appear in the column like a numbered list. I do not understand why..
Hi, thank you for your comment.
ReplyDeleteI think you are saying why we need to use the <ol> <li> elements.
The main reason is to display the breadcrumb list in the search results on Google.
Please see:
https://developers.google.com/search/docs/appearance/structured-data/breadcrumb
If you don't need it, you don't have to use numbered list.
DeleteThanks for the reply. I actually meant that, graphically, the Breadcrums appear one below the other in a numbered bullet list and not in a single horizontal line, as it should be.
Yes, without CSS "display: inline", the breadcrumbs would be displayed vertically. It's a bit a hassle, but it is necessary to modify CSS.
Delete