Get h2 tags from .Content

Hello,

I’m trying to generate JSON-LD for a website I’m currently making. Was wondering if there was a way to pull headling like ## My heading tag from the content to use in json-ld. I’ve searched around and can’t seem to find anything that allows you to pull anything from the .Content section. I was thinking something like.Content.h2 then I could iterate through them to generate json ld.

Here is a link to what im trying to generate. basically want to generate different offers based off of h2 tags
https://schema.org/Service

Any help would be appreciated.
Thank you

You could parse .Content after rendering. Related:
https://discourse.gohugo.io/t/splitting-content-into-sections-based-on-header-level/33749

Or use a heading render hook to store the headings in a page-level Scratch.

Thank you for the response, is there anymore documentation?

Did you try this button?

2 Likes