Hugo gives 404 instead of static page

Hi,

The index page works fine, but other pages give 404.
I don’t use any theme.

$ cat config.toml
baseURL = “http://example.org/
#languageCode = “en-us”
title = “My New Hugo Site”
disableKinds = [“taxonomy”, “taxonomyTerm”]

$ ls layouts/
404.html default.html landing.html partials

$ ls content/
_index.html _services.html _test.html

_index.html starts with
+++
layout = “landing”
title = “Home”
+++

_services.html starts with
+++
layout = “default”
title = “Services”
+++

in browser:
/ works
/services gives 404

Any idea why please?

This is not how the layouts folder works. Please watch the videos on the website - they’ll help you to get your head around Hugo very quickly. Here’s the link: https://www.youtube.com/playlist?list=PLLAZ4kZ9dFpOnyRlyS-liKL5ReHDcj4G3

The author is Mike Dane.

Hope this helps.

Thanks Leo,

I’ve watched most of the videos. Changed layouts to:

$ ls layouts/_default/

default.html landing.html

Still, services page gives 404.

I’m just trying to create a HTML page. Not sure why it’s so hard.

Marius

Hi,

I think it’s because you seem to have html files under your content. Try it with a markdown file instead (i.e. _index.md, services.md etc) and see if the problem persists.

We really need to use html. Is hugo a good fit for this usecase?

Appreciate your time
Marius

Sorry, my mistake, it should apparently work with html files (read: [SOLVED] Using HTML for content pages instead of Markdown).

Do you have draft = false in your frontmatter? (alternatively, run hugo server with the --buildDrafts flag)


Additional notes:

Not sure if the underscore in _services.html is a typo or intentional, but that should render to /_services, not /services (see: Content organization | Hugo )

This may help:

@mariusa Any chance you can share source with us somewhere? Thanks!

We don’t know because we don’t know what your usecase is. Building web sites is complicated, you have to help us help you. :slight_smile:

Please read Requesting Help and follow those steps. Otherwise we have no way of answering your questions.

1 Like

Hi,

Here’s the full source, minimal test case:

http://localhost:1313/services gives 404.

Note: It works if renaming _services.html to services.html, but then the browser is redirected to “services/”. It needs to as a page, without “/” at the end.

Thanks!

Your content files have .html extensions, but inside they are formatted as typical markdown files, which is odd.

You can have a markdown file with frontmatter, and, put html in it mixed with markdown, no problem. So why not try renaming your content files as .md instead.

Note that, you can indeed put “pure” html files in your /static folder, which gets served at the root of your site. That means, /static/path/to/myfile.html is served as http://mysite.com/path/to/myfile.html. In that case hugo won’t process them and just copy them into the site as appropriate, like it would with any other asset like a javascript or image file, under /static.

2 Likes