# Handling of unknown file extensions?

**URL:** <https://discourse.gohugo.io/t/handling-of-unknown-file-extensions/14130>\
**Category:** support\
**Created:** [September 9, 2018, 4:14pm UTC](https://discourse.gohugo.io/t/handling-of-unknown-file-extensions/14130 "2018-09-09T16:14:56Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![pgr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pgr/32/5329_2.png) [@pgr](https://discourse.gohugo.io/u/pgr)\
**Post date:** [September 9, 2018, 4:14pm UTC](https://discourse.gohugo.io/t/handling-of-unknown-file-extensions/14130/1 "2018-09-09T16:14:56Z")

</div>

Hi.

I noticed my site is generating a bunch of `amp` directories, which aren’t intended.

I went to check things and I found out these are the culprits:

```auto
Opportunities.es.adoc.save
Metadata.es.adoc---         
Table of Contents.adoc.NOT

```

So it’s basically left-over files, which should just be deleted, but for some reason (intentional or not) were left behind.

These get rendered in

```auto
./public/amp/user/core-modules/Opportunities.es.adoc.save
./public/amp/developer/Metadata.es.adoc---
./public/amp/developer/Table of Contents.adoc.NOT

```

Two questions:

1. What’s the logic behind assuming these are `amp` format files? They aren’t.

2. Apart from the `ignoreFiles` entry in `config.toml` which let’s us disable a specific list of file extensions, is there a way of asking Hugo to ignore all unknown extensions? That would be my preferred handling of these cases.

Link to my source:

> **[salesagility/SuiteDocs](https://github.com/salesagility/SuiteDocs/)**
>
> Contribute to salesagility/SuiteDocs development by creating an account on GitHub.

  
Thanks!

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [September 9, 2018, 4:23pm UTC](https://discourse.gohugo.io/t/handling-of-unknown-file-extensions/14130/2 "2018-09-09T16:23:23Z")

</div>

Please do read the [Requesting Help](https://discourse.gohugo.io/t/requesting-help/9132) Topic.

It’s the big pink banner at the top of the Forum.

After you read that topic and the Hugo Docs (you may want to look into Output Formats to disable AMP) feel free to open another topic but this time with a more concrete question along with a link to the source code of your Hugo project.

I’m closing this thread because the questions posted are too broad.

Thank you.

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [September 9, 2018, 4:23pm UTC](https://discourse.gohugo.io/t/handling-of-unknown-file-extensions/14130/3 "2018-09-09T16:23:28Z")

</div>

Closed on September 9, 2018, 4:23pm UTC



---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [September 9, 2018, 4:35pm UTC](https://discourse.gohugo.io/t/handling-of-unknown-file-extensions/14130/4 "2018-09-09T16:35:24Z")

</div>

Opened on September 9, 2018, 4:35pm UTC



---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [September 9, 2018, 4:37pm UTC](https://discourse.gohugo.io/t/handling-of-unknown-file-extensions/14130/5 "2018-09-09T16:37:28Z")

</div>

Ok. Since you edited your original post to include a link to your repo I re-opened this topic.

However I still think that your questions are too broad.

In any case maybe someone will look into your repo, but as I said above make sure to read the Documentation about Output Formats, it will show you how to disable AMP (since you don’t want it).

---

<div class="post-metadata">

**Author:** ![pgr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pgr/32/5329_2.png) [@pgr](https://discourse.gohugo.io/u/pgr)\
**Post date:** [September 9, 2018, 4:37pm UTC](https://discourse.gohugo.io/t/handling-of-unknown-file-extensions/14130/6 "2018-09-09T16:37:55Z")

</div>

I just did a second edit to improve the questions. Thanks!

---

<div class="post-metadata">

**Author:** ![pgr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pgr/32/5329_2.png) [@pgr](https://discourse.gohugo.io/u/pgr)\
**Post date:** [September 9, 2018, 4:38pm UTC](https://discourse.gohugo.io/t/handling-of-unknown-file-extensions/14130/7 "2018-09-09T16:38:39Z")

</div>

Note that I am not asking about disabling the `amp` format, I am asking why these files are getting recognized as `amp` format when they aren’t. I don’t think I will find an answer to that in the Documentation. I also read previous posts here about this (there isn’t much).

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [September 9, 2018, 4:40pm UTC](https://discourse.gohugo.io/t/handling-of-unknown-file-extensions/14130/8 "2018-09-09T16:40:50Z")

</div>

> [@pgr](#):
>
> .adoc

An _ADOC file_ is an AsciiDoc file.

It is not an unknown file format. It seems that the theme you use is configured to output these files.

However I need to go now and can’t look into this further.

Thanks.

---

<div class="post-metadata">

**Author:** ![pgr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pgr/32/5329_2.png) [@pgr](https://discourse.gohugo.io/u/pgr)\
**Post date:** [September 9, 2018, 4:51pm UTC](https://discourse.gohugo.io/t/handling-of-unknown-file-extensions/14130/9 "2018-09-09T16:51:45Z")

</div>

I don’t mention any `.adoc` file in my post. I mention files ending in `.NOT`, `.save`, `---`.

My `config-toml` has this (not done intentionally by me, I got it from the theme):

```auto
[outputs]
home = ["HTML", "AMP", "RSS", "JSON"]
section = ["HTML", "AMP", "RSS", "JSON"]

```

So I’m guessing the logic is something like this: _“can’t render this file as HTML, let’s fall back to AMP”_.

For the normal `.adoc` files that do render properly, no `amp` output is generated.

But does this logic make any sense? Maybe it does and it’s just me, I am not seeing it.

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [September 9, 2018, 6:44pm UTC](https://discourse.gohugo.io/t/handling-of-unknown-file-extensions/14130/10 "2018-09-09T18:44:36Z")

</div>

> [@pgr](#):
>
> I don’t mention any `.adoc` file in my post. I mention files ending in `.NOT` , `.save` , `---` .

Well the following _do_ seem like .adoc temp files to me.

> [@pgr](#):
>
> `./public/amp/user/core-modules/Opportunities.es.adoc.save`  
> `./public/amp/developer/Metadata.es.adoc---`  
> `./public/amp/developer/Table of Contents.adoc.NOT`

Also all content files in the Repo you linked to are AsciiDoc files.

> [@pgr](#):
>
> So I’m guessing the logic is something like this: _“can’t render this file as HTML, let’s fall back to AMP”_ .

No that is not how Output Formats work. They exist side by side.

Anyway I am afraid that I cannot be of any further assistance.

Hugo does support [Additional Formats Through External Helpers](https://gohugo.io/content-management/formats/#additional-formats-through-external-helpers) like Asii Doctor but the scope of this Forum is not about providing support for these external helpers.

I recommend that you raise your questions directly to the [Hugo Learn Theme](https://github.com/salesagility/SuiteDocs/tree/master/themes/hugo-theme-learn) repository.

---

<div class="post-metadata">

**Author:** ![pgr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pgr/32/5329_2.png) [@pgr](https://discourse.gohugo.io/u/pgr)\
**Post date:** [September 9, 2018, 7:14pm UTC](https://discourse.gohugo.io/t/handling-of-unknown-file-extensions/14130/11 "2018-09-09T19:14:57Z")

</div>

I must respectfully disagree with you here.

Where front-matter omits Handler definition, Hugo is guessing the file type by the extension:

> <https://github.com/gohugoio/hugo/blob/master/hugolib/page.go#L1509-L1514>

Now, the extension is being grabbed with the `Ext` function, which as you can confirm here will only get the last extension on names with two dots (press “Run” to see the results):

[https://golang.org/pkg/path/filepath/#example\_Ext](https://golang.org/pkg/path/filepath/#example_Ext)

So for the three files I mention, `adoc` is not returned by `Ext`, and `GuessType` will return `unknown` for the helper:

> <https://github.com/gohugoio/hugo/blob/master/helpers/general.go#L75-L94>

(it doesn’t matter that I have tons of valid `.adoc` files elsewhere in my site, this post is not about those, which are handled just fine).

So, we’re back to my Topic title which is asking about **“Handling of unknown file extensions”**.

I would like to understand better how this connects to Output formats, since the behavior I’m seeing now doesn’t make sense to me. Note that my main concern here is for Hugo’s consistency; I can just delete these old files and the problem goes away for me. However, if I’m uncovering something fishy here then it’s a good idea to improve Hugo in this regard. Or we could improve the Documentation.

Thanks.

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [September 9, 2018, 7:43pm UTC](https://discourse.gohugo.io/t/handling-of-unknown-file-extensions/14130/12 "2018-09-09T19:43:10Z")

</div>

First of all I want to point out that I am not a Go Developer.

Second it seems that an Unknown Output Format can be published by design. For example in lines 181-191 of `outputFormat_test.go` there is a test for an Unknown Output Format:

> <https://github.com/gohugoio/hugo/blob/ebb56e8bdbfaf4f955326017e40b2805850871e9/output/outputFormat_test.go#L181-L191>

In the same file there are other tests for HTML, XML, JSON and AMP.

Why is the Unknown Output Format assumed to be AMP in your case?  
I am afraid that I cannot answer your question.

Maybe you should open a bug report on GitHub.

But to be honest this is the first time I’m seeing this type of report in the Forum and I’ve been quite involved here for a while.

Why don’t you simply remove those temp files? Also you can use gitignore to exclude those files.

We all like to optimize our sites, why should the content folder be an exception to this rule?

Also on a friendly note if you do open the GitHub issue please tone down the language a bit, phrases like: “does this logic make any sense?” and “uncovering something fishy” are a bit counter productive.

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:** [September 9, 2018, 7:53pm UTC](https://discourse.gohugo.io/t/handling-of-unknown-file-extensions/14130/13 "2018-09-09T19:53:30Z")

</div>

> [@pgr](#):
>
> is there a way of asking Hugo to ignore all unknown extensions?

No…

---

<div class="post-metadata">

**Author:** ![pgr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pgr/32/5329_2.png) [@pgr](https://discourse.gohugo.io/u/pgr)\
**Post date:** [September 10, 2018, 9:21am UTC](https://discourse.gohugo.io/t/handling-of-unknown-file-extensions/14130/14 "2018-09-10T09:21:26Z")

</div>

@alexandros thanks for your good advice, always welcome.

I do moderation myself for a [big Community](https://suitecrm.com/suitecrm/forum/profile/6776-pgr) and I recognize you’re doing a good job here, you are always polite even when in disagreement. Keep up the good work (and your excellent drawings!).

I also do a lot of Support and bug reporting work [for a very large open-source project](https://github.com/pgorod) and let me tell you my hesitation in taking this to Github… I feel like I need some Forum discussion before opening a bug, because I don’t understand (yet) what the _normal_ behavior is supposed to be.

I need to understand what I’m telling Hugo to do when I put this in my `config.toml`:

```auto
[outputs] 
home = ["HTML", "AMP", "RSS", "JSON"] 
section = ["HTML", "AMP", "RSS", "JSON"]

```

Am I telling Hugo to generate _all_ these outputs for _every_ file (unless I override in the front-matter)? Then why am I not getting any AMP generated for my normal `.adoc` files?

But if Hugo is doing things right, and AMP is not generated because I would need to add some extra stuff to get that, then why is it being generated for unknown file extensions?

Once I have this answer I feel I can be much more specific with my (eventual) bug report.

Note that some of my bogus files are generated “by accident”, without users being aware of it, like the `.save` file which probably comes from a text-editor’s auto-save. So people might be thinking they have removed some content from the site, without realizing the `.save` file is there. They won’t find it as a normal file when they browse the site, but it will be there under some `amp` directory… this sounds like the sort of behavior that could be improved.

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [September 10, 2018, 9:38am UTC](https://discourse.gohugo.io/t/handling-of-unknown-file-extensions/14130/15 "2018-09-10T09:38:04Z")

</div>

Thanks for the comment. I do try.

BTW I also noticed that you are the author of the theme you use.

Well @bep has already replied in this topic. He is probably the only one who can answer your questions provided he has the time.

---

<div class="post-metadata">

**Author:** ![pgr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pgr/32/5329_2.png) [@pgr](https://discourse.gohugo.io/u/pgr)\
**Post date:** [September 19, 2018, 8:59am UTC](https://discourse.gohugo.io/t/handling-of-unknown-file-extensions/14130/16 "2018-09-19T08:59:54Z")

</div>

I’m going to drop this since there seems to be no interest/time to pursue, I will just delete my left-over files.

If one day someone thinks this is worth creating a GitHub issue, let me know, I don’t mind taking care of it.
