Jekyll-style includes?


One of the things that I like about Jekyll is that you can use include statements to borrow pretty much any kind of content. That means that I can add a {% include %} directive in a Markdown file and pull in the entire contents of a different file. I work on very large technical documentation projects and this capability enables me to have redundant content appear in multiple places but I only need to update it once.

As far as I can tell, and correct me if I’m wrong, but this is not possible in Hugo, which for some of my recent projects has more or less forced me to stick with Jekyll. Have any of you found a workaround for this? Is there a reasonable way to do this using shortcodes or partials?

I’ve tried a few things but I just can’t seem to get over the hump of pulling in arbitrary file data into Markdown sources. If I can get over this hump I’ll be back on the Hugo train in a major way.

  • Mmark has include support
  • There are the readFile and markdownify funcs, both of which can be used from shortcodes
  • There is the .Site.GetPage method, even though there are some known limitations that we will eventually fix

So maybe not Jekyll style, but … Hugo style?


I will try all of the above methods! Thanks a lot for the advice. If one of those methods strikes me as useful for others I’ll make sure to come back to the list with some more concrete suggestions, as I imagine others have run into similar constraints.