hugo-preproc

Hugo is amazing. It does a lot of wonderful things.

However, I’ve discovered a few gaps:

  • GitInfo doesn’t play well with Hugo Modules
    • Try separating your content and config into different modules, but would like to use GitInfo for content.
  • GitInfo is only for a current page.
    • What if you’d like to have GitInfo for the Page, but also for the whole Site displayed on the same page?
  • Can’t dynamically generate Pages.
    • Why can’t we generate Pages from Data?
    • Why can’t templates make use of the entire Git log?
  • Can’t make calls out to other tools to handle different source formats.
    • Well, it does, but only for a select few tools.
    • Seemingly no interest from core developers to adopt some sort of modular “exec” method.

Maybe these gaps are peculiar to my uses of Hugo; regardless, I chose to fill the gaps as best I could with a new tool: hugo-preproc.

hugo-preproc offers both Git and Exec handlers. It has a simple YAML configuration syntax, but is relatively powerful in what you can do.

This was written to be used in conjunction with Hugo. Define your processors, and run hugo-preproc before you run hugo in your pipelines, and it can prepare your Hugo site data to be the way you want it before you run Hugo.

I have used this to:

  • Generate detailed Hugo page collections of git logs.
  • Convert Graphviz documents to images.
  • …and more.

As CI/CD capabilities become more native to our version control platforms, perhaps this tool seems obsolete. One could surely do this with additional steps in your pipelines, but at least with the Git processing, it does allow for rapid development of Git logs to Hugo pages with no coding necessary.

It’s just another tool in the toolbox.

Project link: https://github.com/jason-dour/hugo-preproc