Improving SEO with JSON-LD Breadcrumbs
I've added a new script the the .app/
folder, called breadcrumb
.
This script is called by create_page
, when generating a pages meta HTML.
The usage for breadcrumb
is simply to pass a URL to it:
breadcrumb posts/2019/03/10/improving-seo-with-json-ld-breadcrumbs.html
It will print (to stdout) a (hopefully) valid JSON-LD BreadcrumbList
like this one:
<script id="breadcrumb-ld" type="application/ld+json">{
"@context": "http://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"item": {
"@id": "https://sc0ttj.github.io/mdsh",
"name": "mdsh - Mdsh"
}
},
{
"@type": "ListItem",
"position": 2,
"item": {
"@id": "https://sc0ttj.github.io/mdsh/posts",
"name": "mdsh - Posts"
}
},
{
"@type": "ListItem",
"position": 3,
"item": {
"@id": "https://sc0ttj.github.io/mdsh/posts/2019",
"name": "mdsh - Posts from 2019"
}
},
{
"@type": "ListItem",
"position": 4,
"item": {
"@id": "https://sc0ttj.github.io/mdsh/posts/2019/03",
"name": "mdsh - Posts from March 2019"
}
},
{
"@type": "ListItem",
"position": 5,
"item": {
"@id": "https://sc0ttj.github.io/mdsh/posts/2019/03/08",
"name": "mdsh - Posts from March 2019"
}
},
{
"@type": "ListItem",
"position": 6,
"item": {
"@id": "https://sc0ttj.github.io/mdsh/posts/2019/03/08/unpublishing-pages.html",
"name": "mdsh - Unpublishing pages"
}
}
]
}</script>
The above JSON-LD was generated by breadcrumb
. Here is the contents of the breadcrumb
script: