Hi All,
Long time no posting or visiting. I am in the process of updating my blog. I was wondering if anyone could confirm or deny that my current breadcrumb system is ok for Google SEO or not.
Theme: BeautifulHugo
I have a fairly simple structure
contents→post (Most posts live here)
contents→post→python (contains _index.md) standard sub-branch
contents→post→rust (no index.md or _index.md)
My breadcrumbs.html partial is currently this
{{- $items := slice -}}
{{- $position := 1 -}}
{{/* Home */}}
{{- $items = $items | append (dict
"@type" "ListItem"
"position" $position
"name" "Home"
"item" .Site.BaseURL
) -}}
{{/* Loop through Ancestors */}}
{{- range where .Ancestors.Reverse "IsHome" false -}}
{{- $position = add $position 1 -}}
{{/* Get Directory name .Title is not set */}}
{{- $segments := split (trim .Path "/") "/" -}}
{{- $last := index $segments (sub (len $segments) 1) -}}
{{- $title := .Title | default $last -}}
{{- $items = $items | append (dict
"@type" "ListItem"
"position" $position
"name" $title
"item" .Permalink
) -}}
{{- end -}}
{{/* Current page */}}
{{- if not .IsHome -}}
{{- $position = add $position 1 -}}
{{- $items = $items | append (dict
"@type" "ListItem"
"position" $position
"name" .Title
"item" .Permalink
) -}}
{{- end -}}
<script type="application/ld+json">
{{ dict
"@context" "https://schema.org"
"@type" "BreadcrumbList"
"itemListElement" $items
| jsonify (dict "indent" " ") | safeJS }}
</script>
This works well for directories that have a _index.md so my crumb give the full path.
I also have directories like “rust”, “hugo” which do not contain any “_index.md” or “index.md” and my code generates the following
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{
"@type": "ListItem",
"item": "http://localhost:1313/",
"name": "Home",
"position": 1
},
{
"@type": "ListItem",
"item": "http://localhost:1313/post/",
"name": "BlogPostings",
"position": 2
},
{
"@type": "ListItem",
"item": "http://localhost:1313/post/rust/decon-spf-0-2-6/",
"name": "Decon-Spf Version 0.2.6",
"position": 3
}
]
}
</script>
Note the leap from /post/ in position 2 and /post/rust/decon-spf-0-2-6/ for position 3.
The directory /rust/ returns a 404 which I expect.
My question is will SEO have issues with this? Or is this bad SEO?
Note: The default breadcrumb builder for BeautifulHugo is currently hardcoded, so I am trying to create something more dynamic.
Thougts and suggested requested.