Custom content type to call a user defined Go function

I am investigating static blog site generators for one that supports the following scenario.

I write code for my blog posts using a form of literate programming by adding markdown text as comments to my code (i.e. I then have a converter program that take the code file as input and generates correct markdown that I then copy and paste as a blog post.

I am looking to optimise my workflow even more, by having each one of my blog posts to be just a front matter containing the link to the github code file. By seeing this front matter (or the file extension or whatever else), the framework would call my own function to convert it to markdown and generate the correct html. This is superior to my current workflow as any change to the code file is automatically reflected in a change to the blog post every time I recompile the site.

In summary, is there a way to insert your own Go function in the content rendering pipeline to pre-process a user defined content type?

I don’t know the answer to your question. I do know Hugo is fast and can be chained with other apps very easily.

If I were doing this, I would probably keep all these together in one or two repos, and build the site whenever your literate programming repo is updated. Have the CI run your conversion script, outputting the markdown into the content directory you want, build site. That’s a fairly common workflow.

I’m sure other folks will have more thoughts. :slight_smile:

Thanks Maiki.

That’s pretty much where I landed to. Pre-process the posts containing the links to the literate code files and generate the markdown files in the directory where Hugo wants them to. Then run Hugo to generate the site.

I was wondering if it were possible to have a deeper integration to avoid the pre-processing step.