I wanted to post my finding here as I spend quite a few days figuring this out. Still, I want to thank this post as it put me on the right track.
If you want to apply separate logic to the different output formats you use, you can do that by creating separate render-hook or template files under layouts
. For example, to change how headings’ autolinks are rendered, create:
layouts/_default/_markup/render-heading.html
layouts/_default/_markup/render-heading.xml
So far so good. In the case of the Docsy theme, however, it creates a custom output format called print
, defined as follows (in config.toml
):
[outputFormats]
[outputFormats.PRINT]
baseName = "index"
isHTML = true
mediaType = "text/html"
path = "_print"
permalinkable = false
I assumed I needed to create layouts/_default/_markup/render-heading.print
to customize it, but I was wrong. I needed to use the following name instead:
layouts/_default/_markup/render-heading.print.html
I’d appreciate any further input from Hugo maintainers explaining the full logic behind building these filenames.