Hugo: Heading level offset

Created on 28 Sep 2019  路  6Comments  路  Source: gohugoio/hugo

Many markup processors, including blackfriday, support offsetting heading levels. this is key when composing content, say into a single big page, or a few pages.

There's a hacky way of doing this in the forums, but this breaks shortcode usage, and a bunch of other things.

This can be solved by just being able to set:

blackfriday.HTMLRendererParameters.HeadingLevelOffset = level

This can't be a config-wide thing though (as many of the other blackfriday parameters are). It has to be set per render call, and likely cannot be set in the page itself (ie the source page may not know the level of header it should offset to, only its caller may).

So, basically, when calling something like the following:

{{ $b := $a.GetPage foo }}
{{ $b.Content }}

It should be possible to set params to blackfriday for the that page's render:

{{ $b := $a.GetPage foo (dict "config" blackfridayCfg) }}
{{ $b.Content }}

or even something like this (change it every time)

{{ $prev :=  .Config.HeadingLevelOffset }}
{{ .Config.HeadingLevelOffset = $level }}
{{ $b := $a.GetPage foo }}
{{ $b.Content }}
{{ .Config.HeadingLevelOffset = $prev }}

Most helpful comment

Bump again

All 6 comments

This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help.
If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.
If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.
This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.

This is something that would still be useful. I made a custom partial that uses some regex substitutions to get around this but native support would be much better.

This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help.
If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.
If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.
This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.

Bump again

This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help.
If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.
If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.
This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.

Not stale afaik

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chrissparksnj picture chrissparksnj  路  3Comments

vielmetti picture vielmetti  路  3Comments

mumblecrunch picture mumblecrunch  路  3Comments

digitalcraftsman picture digitalcraftsman  路  3Comments

sigma picture sigma  路  3Comments