Why is my only page in Hugo returning an HTTP 404 error?

I am trying to create a site with Hugo , but I donโ€™t understand how to add one page to my site (messages work fine).

Starting with the new version (v.0.27 64x for Windows) and running the following command from my terminal:

> hugo new site soexample > cd soexample > git clone https://github.com/parsiya/Hugo-Octopress.git themes\octopress > hugo new about.md > echo "Please display me" >> content\about.md > hugo serve -D -t octopress 

I see that my draft page is displayed from the output of the last command:

 ... Built site for language en: 1 of 1 draft rendered ... 

but when I try to access http://localhost:1313/about/ or http://localhost:1313/about.html , the server (not the browser) returns a white page using

 404 page not found 

What am I missing?

+5
source share
2 answers

The problem arises from the selected default theme, which does not display a separate page outside of section messages. Themes can be tricky for newbies, as hugo is not shipped by default, and the official theme is not recommended or supported (so newbies may have to choose randomly).

So, the following commands worked for me:

 > hugo new site soexample > cd soexample > git clone https://github.com/spf13/hyde.git themes\hyde > hugo new about.md > echo "Please display me" >> content\about.md > hugo serve -D -t hyde 

The page http://localhost:1313/about/ displayed.

+4
source

To render offline pages in Hugo, you need to set the page type and make sure that you have a โ€œsingleโ€ template in your layouts.

In the front question about.md, set 'type' to 'page'. In the layouts folder in the _default folder, make sure you have a single.html file.

In order for it, the / about page should now display correctly.

0
source

Source: https://habr.com/ru/post/1271787/


All Articles