Pre-processing of files

Is there any official support for pre-proccessing of content?

What I want to be able to do is run some scripts over the pages before the main build is run. There are a few things I want to be able to do:

  • Generate pages from data
  • Duplicate pages with the layout tweaked

I would like these things to be run automatically when I call hugo so that I don’t have to run multiple scripts to build my site.


Example scenario…

I have a newsletter type in Hugo that I want to render as both a page on my site and an email template. When processing I want to:

  1. Duplicate the page with a different layout (one that renders the full page as the email)
  2. Call my mail tool API to sync any changes to the campaign based on the front matter. (schedule, subject, etc…)

Of course, I can run a script before the build, but it would be much more elegant if we had a folder of scripts that we can have Hugo execute in order before the build is executed.

I’m happy to learn some Go to achieve this.

You may not trigger your own scripts from inside hugo. Plugging in some Go code would need to build your own Hugo fork.

Usually you would create a wrapper that does your stuff and finally calls hugo.

For data and page generation have a look at

External API calls are possible using

1 Like

Love it… thanks! Just what I was looking for…