Anchor link at template level

I read Why are anchor links not available to pages?.
I know it’s again Section vs Page.
I still would like to express the need for this feature (doc) at the template level. When making a generic theme aiming to be used by someone else, I feel like it’s more appropriate to tell

set template = "example.html" in your front matter, the template will take care of your content

than

set insert_anchor_links = "heading" in your front matter, but only for sections that use example.html template, and insert_anchor_links = "right" for others that use the page.html default for their pages

It’s the same kind of thing as having the user insert [TOC] at the position where he wants the table of content to be inserted, while a macro called by the template takes care of this.

I feel like these things belong more to templating than content metadata, and so the current way of specifying this makes writing content-independent theme cumbersome.

In concrete terms, it could mean to have an insert_anchor_links filter, but that’s maybe a too big task for a filter.

In concrete terms, it could mean to have an insert_anchor_links filter, but that’s maybe a too big task for a filter.

If you do it in the template, you need to parse HTML and edit it. It also means the content will be different if you get it later with get_section/get_page compared to its own page

1 Like