Override defaultMarkdownHandler in frontmatter

Scenario: For the pages of some sections, I need a pretty heavy preprocessing, which I implemented in python as a pandoc filter, and then I set defaultMarkdownHandler: pandoc.

This works, but it’s extremely slow. Commenting out the defaultMarkdownHandler config line, it takes 20 times less for the whole website (which is pretty small, too).

I assume that the overhead of spawning pandoc, which in turn spawns python, for every page and for every markdownify, is to blame.

So, is there a way to specify which handler to use on a per-page level? Here it says some markdown config can be overridden, but not which or how.

I tried this:

title: ...
# ...
  defaultMarkdownHandler: goldmark

but no effect.

If it is not possible, is this something that would be acceptable/accepted (I can try to make a MR)?

If not, how would one go about solving this? The build time is simply unacceptable in my case.

Please clarify:

  1. Are some of your pages pandoc, and some markdown?

  2. If yes, what percentage are pandoc?

  3. If yes, does your structure look like this:

 ├── posts/
 │   ├── post-1.md
 │   └── post-2.pdc
 └── _index.md

Or do all files have the same extension?

Sorry, should have specified!

They are all markdown, but in Pandoc’s flavour. All with .md extension.

But if that’s an impediment, I’m happy to either:

  • rename the ones I want processed by Pandoc to another extension
  • or convert from pandoc flavour to hugo’s default flavour
  • or both

The easiest way to handle this is to use the .pdc extension for files to be rendered with pandoc.

Ohhh. Silly me!

I must have read but not registered the first paragraph here.


markup: pandoc

in the frontematter works. And I assume also changing the extension.

Sorry for the noise!

Maybe a link from the page I first linked to this one would be helpful for others looking for similar information?

Order of precedence:

  1. Front matter value (markup = 'pandoc')

  2. File extension (.pdc or .pandoc)

  3. Site configuration

    defaultMarkdownHandler = 'pandoc'