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

**URL:** <https://discourse.gohugo.io/t/can-i-render-a-template-md-file-as-just-text-i-e-back-to-markdown/28674>\
**Category:** support\
**Created:** [October 5, 2020, 7:06pm UTC](https://discourse.gohugo.io/t/can-i-render-a-template-md-file-as-just-text-i-e-back-to-markdown/28674 "2020-10-05T19:06:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dkebler](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/dkebler/32/7285_2.png) [@dkebler](https://discourse.gohugo.io/u/dkebler)\
**Post date:** [October 5, 2020, 7:06pm UTC](https://discourse.gohugo.io/t/can-i-render-a-template-md-file-as-just-text-i-e-back-to-markdown/28674/1 "2020-10-05T19:06:19Z")

</div>

I was hoping to use Hugo (ie. go templates) to render obviously html but also in the case of a readme.md 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](https://gohugo.io/templates/introduction/) ie.[golang text/template](https://golang.org/pkg/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. readme.md) 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.

```auto
package main

import (
        "log"
        "os"
        "text/template"
)

type Person struct {
        Name string
        Emails []string
}

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

func main() {
        person := Person{
                Name: "Satish",
                Emails: []string{"satish@rubylearning.org", "satishtalim@gmail.com"},
        }

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

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

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

```

---

<div class="post-metadata">

**Author:** ![Hrishikesh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/hrishikesh/32/19176_2.png) [@Hrishikesh](https://discourse.gohugo.io/u/Hrishikesh)\
**Post date:** [October 5, 2020, 7:15pm UTC](https://discourse.gohugo.io/t/can-i-render-a-template-md-file-as-just-text-i-e-back-to-markdown/28674/2 "2020-10-05T19:15:40Z")

</div>

.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: [https://gohugo.io/variables/page/#page-variables](https://gohugo.io/variables/page/#page-variables)

---

<div class="post-metadata">

**Author:** ![pointyfar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pointyfar/32/5797_2.png) [@pointyfar](https://discourse.gohugo.io/u/pointyfar)\
**Post date:** [October 5, 2020, 10:25pm UTC](https://discourse.gohugo.io/t/can-i-render-a-template-md-file-as-just-text-i-e-back-to-markdown/28674/3 "2020-10-05T22:25:15Z")

</div>

> [@dkebler](#):
>
> take a single content file (e.g. readme.md) and render it back as markdown instead of into html?

You can configure Hugo to generate `md` as a custom output format: [Custom output formats | Hugo](https://gohugo.io/templates/output-formats)
