Pro / Con: Hugo as Markdown file integrator

I think would like to leverage Hugo’s system of partials, includes, shortcodes, internationalization, themes, etc. to unify the well-factored, functionally separate Markdown assets to produce “integrated” markdown files. Example:


# Markdown is Great

* yes!
* si!

{ partial "copyright.html" . }

Desired Output:

# Markdown is Great

* yes!
* si!

Copyright Yo Hugo Press Inc. [our site](

I do not want to go that additional step that turns that output ^^^^ HTML. From a stream metaphor, I’d like to shunt the output out before it goes through the markdown pipe.


  1. Is this a sensible thing?
  2. By dropping the HTML capability, and I losing so much of the Hugo goodness that I might as well just roll my own document synthesis app?
  3. Is this a path with any previous travelers?

Thanks for helping me evaluate my next move!


There are a few ways to accomplish what you want. See below for some I have used in the past.

Using a shortcode

Create the shortcode at layouts/shortcodes/copyright.html, then define it as:

{{ partial "copyright.html" . }}

Then use it in your markdown like:

# Markdown is Great

* yes!
* si!

{{< copyright >}}

Using a front matter param in your template

Specify a param in your markdown front matter. Something like:

copyright: true

Then in your template (let’s pretend it’s at layouts/_default/single.html) only show the copyright partial if the param is true:

<h1>{{ .Title }}</h1>
{{ .Content }}

{{ if eq .Params.copyright true }}
  {{ partial "copyright.html" . }}
{{ end }}
1 Like

Is what a sensible thing? The task you’ve asked about? Why are you doing it? Then maybe we can say. :slight_smile:

Yes. But Hugo uses other libraries and such to do it’s thing, and the source is free, so that shouldn’t be too much pain. But, if you do figure it out, you can just pin it to that version of Hugo, and keep the binary, and you will be set for life!

I don’t know. I kinda make text files for gopher sites with custom outputs, and you could turn off HTML output and probably be most of the way there.

Actually, if the idea is to produce markdown code from a shortcode, I’m pretty sure it can be done by setting a new custom output format called .mdown or something like that.

The result would be the markdown files without any frontmatter.

I think I might have misdirected this discussion by trying to provide an example. Let me try to be more plain.

Ultimately I want the benefit of writing source material in markdown and emitting, markdown (not HTML). I want to leverage all the brilliance of Hugo’s variables and theme structure, the partial directive, etc, but at the end of the day in the output directory e.g. public I want…markdown files.

Is that possible? Or is the idea of not rendering to HTML so foreign to Hugo that I’d be better off using a different framework?

@sgharms use a custom output format and turn off HTML.

I don’t think anyone is going to advise you to use or not use Hugo for your project. You should just try it, see if it works for you.

1 Like

Ultimately my solution was the following:

## This is some markdown

Some Debugging stuff...
{{ .Kind }}


{{ .RawContent }}

## End of markdown

This, paired with custom output type, seems to work pretty well. .RawContent allowed me to avoid the conversion.