Create a specific "content/something.md" page that will be render "something.html"

Hi all,

For any reason (in my curious head) I’m searching for a way to generate a page called something.html in the public directory.

In reality, I want to use 404 pages. Which works as explained in documentation. In fact it would be better to have 404.html files in an public/errors directory. Especially with this wording: public/errors/err404.html.

Does someone have an idea about how I could resolve this kind of problem and generate public/errors/something.html file with a specific layout (404.html one)?

Thanks in advance :wink:

https://github.com/gohugoio/hugo/issues/8924#issuecomment-904765323

Thanks for your message.

I check it, I test it and it appears that it generates a public/errors/404/index.html where I’m expecting a public/errors/404.html or in my case a public/errors/err404.html file.

Am I missing something? :thinking:

Yes, this can be adjusted, but do you need to? Typically on your host (server, service) you can specify the path to each error page. Are you limited in this regard?

Yes, I’m very limited by thttpd (Cf. thttpd man page). Regarding previous link, I need to have an errors/err404.html. No possible other configuration.

I check a little bit more the Hugo documentation and find this: URL Management | Hugo

If I add a file content/errors/err404.html with the following content, it creates a err404.html file:

+++
draft = false
title = "Page non trouvée !"
url = "errors/err404.html"
+++

The remaining problem: Hugo generates public/errors/index.html and public/errors/index.xml and public/errors/page/1/index.html. It’s not perfect but more effective than previously.

Is there also a tip for these index.html files to disappear?

Edit: I found the problem, to avoid having index.html files, I need to add this header in content/errors/_index.md file:

+++
[_build]
  list = 'never'
  render = 'never'
[cascade._build]
  list = 'never'
+++

I forgot using +++ :sweat_smile:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.