Can I render a template md file as just text (i.e back to markdown)

I was hoping to use Hugo (ie. go templates) to render obviously html but also in the case of a file back into markdown so it can be used in git repo. One markdown file containing go template syntax to both output formats.

According to the docs Hugo uses text/template ie.golang text/template.

So rather than make my own text/template renderer is it possible (via cli or a module) to get Hugo to take a single content file (e.g. and render it back as markdown instead of into html?

Not that it’s that hard to do this like below but as function accepting the template (ie. md) and data object. I’m only wondering if it’s supported because Hugo is already using text/template.

package main

import (

type Person struct {
        Name   string
        Emails []string

const tmpl = `
# {{$name := .Name}}
{{range .Emails}}
    **Name is {{$name}}, email is {{.}}**

func main() {
        person := Person{
                Name:   "Satish",
                Emails: []string{"", ""},

        t := template.New("Person template")

        t, err := t.Parse(tmpl)
        if err != nil {
                log.Fatal("Parse: ", err)

        err = t.Execute(os.Stdout, person)
        if err != nil {
                log.Fatal("Execute: ", err)

.RawContent returns the raw Markdown of a file. However, I’m not sure what the above code is (my skill level isn’t as much). So, I don’t know how you can implement it. But yeah, the Hugo page variable you’re probably looking for is .RawContent. Check it out here:

You can configure Hugo to generate md as a custom output format: