# How to use the new Custom Output Formats

**URL:** <https://discourse.gohugo.io/t/how-to-use-the-new-custom-output-formats/6318>\
**Category:** support\
**Created:** [April 24, 2017, 5:54pm UTC](https://discourse.gohugo.io/t/how-to-use-the-new-custom-output-formats/6318 "2017-04-24T17:54:07Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![tutume](https://avatars.discourse-cdn.com/v4/letter/t/7ea924/32.png) [@tutume](https://discourse.gohugo.io/u/tutume)\
**Post date:** [April 24, 2017, 5:54pm UTC](https://discourse.gohugo.io/t/how-to-use-the-new-custom-output-formats/6318/1 "2017-04-24T17:54:07Z")

</div>

Hi,

I’m trying to use the new Custom Output Format feature.

My hugo version is Hugo Static Site Generator v0.20.3 windows/amd64 BuildDate: 2017-04-24T14:09:50-03:00

I want to generate a .htaccess file  
file [hugoroot]/layouts/.htaccess  
RewriteEngine On  
RewriteCond %{HTTP\_HOST} ^domain.com$ [NC]  
RewriteRule ^(.\*)$ {{ .Site.BaseURL }}/$1 [R=301,L]

In my confing.toml I have added  
[mediaTypes]  
[mediaTypes.“text/htaccess”]  
suffix = “htaccess”

```
[outputFormats.htaccess]
mediaType = "text/htaccess"
baseName = "txt"
isPlainText = true

```

I have tried to do almost same thing with robots.txt file  
file [hugoroot]/layouts/.htaccess

I didn’t put anything on config.toml file as I understood the text/plain format is already build-in.

But nothing is generated on both cases.

How do I do these two things?

Thanks

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [April 24, 2017, 8:14pm UTC](https://discourse.gohugo.io/t/how-to-use-the-new-custom-output-formats/6318/2 "2017-04-24T20:14:42Z")

</div>

1. You need to name your layout file according to the documentation.
2. I assume you will currently not be able to have a blank filename (".htaccess"), you could set `baseName=""`, but I suspect it will default to `index`.
3. You need to define your new format in a `outputs` definition.

---

<div class="post-metadata">

**Author:** ![tutume](https://avatars.discourse-cdn.com/v4/letter/t/7ea924/32.png) [@tutume](https://discourse.gohugo.io/u/tutume)\
**Post date:** [April 25, 2017, 4:11pm UTC](https://discourse.gohugo.io/t/how-to-use-the-new-custom-output-formats/6318/3 "2017-04-25T16:11:06Z")

</div>

Hi,

Thanks for your answer. But I still not able to make it work.

I have created a new test project at [https://github.com/tutume/hugotests](https://github.com/tutume/hugotests)  
There, I have the following config.toml

baseurl = "[https://domain.com/](https://domain.com/)"  
languageCode = "en-us"  
title = "Testing Hugo"  
theme = “hugo\_theme\_robust”

[mediaTypes]  
[mediaTypes.“text/htaccess”]  
suffix = “htaccess”

[outputFormats]  
[outputFormats.MyHTA]  
mediaType = "text/htaccess"  
baseName = ""  
isPlainText = true

[outputs]  
home = [“HTML”, “MyHTA”]  
page = [“HTML”, “MyHTA”]

[Params]  
Domain = "[domain.com](http://domain.com)"  
Author = “Ricardo Tutume”

and Inside layouts (not theme/layouts) I have  
file [apache.MyHTA.htaccess] with  
RewriteEngine On  
RewriteCond %{HTTP\_HOST} ^{{ .Param.Domain }}$ [NC]  
RewriteRule ^(.\*)$ {{ .Site.BaseURL }}/$1 [R=301,L]

Sorry by my dummy question. But What Am I doing wrong?

I have followed info from

> **[Custom Output Formats: The last piece of the puzzle](https://discourse.gohugo.io/t/custom-output-formats-the-last-piece-of-the-puzzle/6033)**
>
> There are some small details left, but I just finished the last major bits of the "Custom Output Formats" feature. I have demo-wrapped them up in the two commits below. The last commit is a bit constructed, but shows how to configure custom...

I even tried to use your repo and I cannot see layouts/\_default/list.MyEnrichedFormat.enr been generated anywhere.

I’m trying to generate .htaccess and robots.txt as are some basic files that I need, but I will do more things in the future like generating custom php files, etc.

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [April 25, 2017, 5:28pm UTC](https://discourse.gohugo.io/t/how-to-use-the-new-custom-output-formats/6318/4 "2017-04-25T17:28:32Z")

</div>

See [https://github.com/tutume/hugotests/pull/1](https://github.com/tutume/hugotests/pull/1)

It looks a little surprising that the Output Format name must be lower-cased in the template (please file an issue about that on GitHub), but otherwise it actually works pretty good. I suspected you would have to do some trickery to get .htacess work without the base in the filename, but this worked fine:

[http://localhost:1313/.htaccess](http://localhost:1313/.htaccess)

---

<div class="post-metadata">

**Author:** ![tutume](https://avatars.discourse-cdn.com/v4/letter/t/7ea924/32.png) [@tutume](https://discourse.gohugo.io/u/tutume)\
**Post date:** [April 25, 2017, 9:36pm UTC](https://discourse.gohugo.io/t/how-to-use-the-new-custom-output-formats/6318/5 "2017-04-25T21:36:42Z")

</div>

Many thanks for the help. It work! Although I didn’t understood how it really works.

Sorry by asking and is there anywhere documented how it exactly works? because at [Output Formats](https://hugodocs.info/templates/output-formats/) docs I couldn’t find anything regarding how to name the template files (like the filename name must have be list.[kind].[suffix])

I will submit the issue regarding the lower-cased template filename.

Anyway, thanks for your help. I will study more how hugo works and maybe I will figure it out.

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [April 25, 2017, 9:50pm UTC](https://discourse.gohugo.io/t/how-to-use-the-new-custom-output-formats/6318/6 "2017-04-25T21:50:58Z")

</div>

> [@tutume](#):
>
> Sorry by asking and is there anywhere documented how it exactly works?

If you don’t understand the current documentation, I cannot help you (I wrote that, and thought it would be sufficient).

It will probably improve eventually, and it will be easier once the examples pop in the wild.

But I got one tip for you:

Think about how templates are handled and selected for the HTML template type in Hugo (fairly documented). Then apply that logic to another Output Format of choice.

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [April 25, 2017, 9:57pm UTC](https://discourse.gohugo.io/t/how-to-use-the-new-custom-output-formats/6318/7 "2017-04-25T21:57:48Z")

</div>

Oh and @tutume – the docs you are linking to is not the official Hugo docs, see [https://gohugo.io/extras/output-formats/](https://gohugo.io/extras/output-formats/)

@rdwatters – could you make it look less official? Maybe drop the domain and just use the full Netlify URL?

---

<div class="post-metadata">

**Author:** ![tutume](https://avatars.discourse-cdn.com/v4/letter/t/7ea924/32.png) [@tutume](https://discourse.gohugo.io/u/tutume)\
**Post date:** [April 25, 2017, 10:19pm UTC](https://discourse.gohugo.io/t/how-to-use-the-new-custom-output-formats/6318/8 "2017-04-25T22:19:39Z")

</div>

Thanks again for your tip. I have to study more and read about.

---

<div class="post-metadata">

**Author:** ![rdwatters](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/rdwatters/32/2848_2.png) [@rdwatters](https://discourse.gohugo.io/u/rdwatters)\
**Post date:** [April 25, 2017, 10:37pm UTC](https://discourse.gohugo.io/t/how-to-use-the-new-custom-output-formats/6318/9 "2017-04-25T22:37:11Z")

</div>

> [@bep](#):
>
> could you make it look less official? Maybe drop the domain and just use the full Netlify URL?

For what? Hugodocs.info? I can start using this moving forward if you prefer:

[https://hugodocsconcept.netlify.com/](https://hugodocsconcept.netlify.com/)

But I’ve been soliciting feedback consistently from the forums and users with the hugodocs.info URL, and there is no real difference in the output formats documentation.

**[[EDIT]]**  
I see the URL you are using, but again, the content is the same…
