You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In most of the recent (Statamic) projects we are forced by SEO agencies to have "speaking" urls with only 1 segment, e.g. https://customer.com/this-is-my-fancy-product instead of https://customer.com/products/fancy. While there's still a /products index page (and products are organized as children of this page), the url structure is flattened.
This is also widely used all over the web. One example is Apple's Mac Book Pro page. The url is https://www.apple.com/macbook-pro/ and only has 1 segment. The breadcrumbs at the bottom of the page look like this: .
What we need is to output the hierachy structure for UX (users) and for search bots somewhere, as breadcrumbs and/or in hidden json schema tags (aka BreadcrumbList).
In Statamic we do have hierarchical collections / navigations but imHo it's not easy to bring this hierachy to the frontend without touching the url structure ({parent_uri}/{slug} vs. {slug}), e.g.
Most of the common SEO addons rely on the nav:breadcrumbs tag which relies on the url structure. There's also a note in the docs that "Breadcrumbs don't follow structures, they follow the current URL hierarchy."
I did not find any hint on how this could be achieved except this unanswered discussion, so I just wanted to share our approach and happy to have your feedback. Mabye this can also lead to a PR somehow.
We implemented a custom tag based on the Structure tag, inspired by the Nav tag.
It only keeps the pages within the "path" of the current page.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
In most of the recent (Statamic) projects we are forced by SEO agencies to have "speaking" urls with only 1 segment, e.g.
https://customer.com/this-is-my-fancy-product
instead ofhttps://customer.com/products/fancy
. While there's still a/products
index page (and products are organized as children of this page), the url structure is flattened.This is also widely used all over the web. One example is Apple's Mac Book Pro page. The url is
.
https://www.apple.com/macbook-pro/
and only has 1 segment. The breadcrumbs at the bottom of the page look like this:What we need is to output the hierachy structure for UX (users) and for search bots somewhere, as breadcrumbs and/or in hidden json schema tags (aka BreadcrumbList).
In Statamic we do have hierarchical collections / navigations but imHo it's not easy to bring this hierachy to the frontend without touching the url structure (
{parent_uri}/{slug}
vs.{slug}
), e.g.nav:breadcrumbs
tag which relies on the url structure. There's also a note in the docs that "Breadcrumbs don't follow structures, they follow the current URL hierarchy."I did not find any hint on how this could be achieved except this unanswered discussion, so I just wanted to share our approach and happy to have your feedback. Mabye this can also lead to a PR somehow.
We implemented a custom tag based on the
Structure
tag, inspired by theNav
tag.It only keeps the pages within the "path" of the current page.
This is how it looks atm:
In Antlers this can be used like this:
An example collection looks like this:
While we have a url structure for the pages collection with only the
{slug}
, we can now use the desired hierachy to output the proper breadcrumbs.This also works with navigation structures.
Happy to hear your comments!
Beta Was this translation helpful? Give feedback.
All reactions