frjo / hugo-theme-zen

A fast and clean Hugo base theme with css-grid and Hugo pipes support.
https://zen-demo.xdeb.org/
GNU General Public License v2.0
276 stars 80 forks source link

Add schema.org BreadcrumbList to JSON+LD #87

Closed danielfdickinson closed 1 year ago

danielfdickinson commented 1 year ago

This implementation depends on .Page.Ancestors, which requires Hugo version v0.109.0.

I expect changes to be requested, hence the 'Draft' PR type.

If v0.109.0 is too high to require, I'll work on a non-.Ancestors option for older versions of Hugo.

frjo commented 1 year ago

Can you also keep an eye on the generated HTML. I know it does not matter from a technical point but I like when it looks nice.

danielfdickinson commented 1 year ago

I prefer nice-looking HTML too, so I will work on that as well.

danielfdickinson commented 1 year ago

Can you also keep an eye on the generated HTML. I know it does not matter from a technical point but I like when it looks nice.

Okay, I started with this. I ended having a lot more difficulty convincing it to format properly than I expected. Using safeJS as a function instead via a pipe (|) seems to be necessary, for some reason.

danielfdickinson commented 1 year ago

Please let me know if you want more documentation (or any other changes, of course).

frjo commented 1 year ago

@danielfdickinson Thanks for this nice contribution!

I made some minor code style changes and moved the call to safeJS into the "meta_breadcrumb_json_ld.html" file.

Can you test so I didn't mess it up?

frjo commented 1 year ago

Get no warnings or errors when checking on https://validator.schema.org/, nice!

danielfdickinson commented 1 year ago

I'll double-check shortly, but don't expect any issues. Thank you!

danielfdickinson commented 1 year ago

Can you test so I didn't mess it up?

It's working on my test site https://dfd-hugo-theme-zen.demo.wildtechgarden.com and the blog I've updated https://www.danielfdickinson.ca.

Looks good to me.