Hugo-coder: How to add custom 404 page?

Created on 20 Aug 2020  ·  8Comments  ·  Source: luizdepra/hugo-coder

Hi!

Like in the topic I would like to add to my page custom 404 page. I followed the official tutorial, but it doesn't work with this theme. I got something what is shown on the picture below:
Zrzut ekranu z 2020-08-20 10-24-26
Is there any way to add such a page with this theme?

Thanks in advance!

Most helpful comment

@clement-pannetier and @luizdepra overriding layouts/partials/404.html works! Thanks a lot for your help! :)

All 8 comments

Well, this theme provides a default 404 page as you can see here.

Are you trying to customize it?

But I need to mention that you'll be unable to see the 404 page if you're testing your deployment with hugo server command.

From official docs:

hugo server will not automatically load your custom 404.html file, but you can test the appearance of your custom “not found” page by navigating your browser to /404.html.

When I run hugo server and I go on http://localhost:1313/404.html I see theme default 404 page. But I would like to customize it :) How can I do that?

Hi @PiotrWachulec, to customize the 404 page, you have to change this file.

Ok, so when I added this theme as submodule then I can have problems with updating theme when I will change this file.

I don't remember now, but I think you can override only this file by creating layouts/404.html on your site root. But I may be wrong.
You also can fork this project, change what you want and use the fork as a submodule.

I don't remember now, but I think you can override only this file by creating layouts/404.html on your site root. But I may be wrong.

👍 but to override the 404.html file you have to create it under layouts/partials/404.html not layouts/404.html.

Ok, I'll try to override it under layouts/partials/404.html and I'll get back with the answer. Thanks @luizdepra and @clement-pannetier !

@clement-pannetier and @luizdepra overriding layouts/partials/404.html works! Thanks a lot for your help! :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

M-Brody picture M-Brody  ·  6Comments

clement-pannetier picture clement-pannetier  ·  3Comments

swarnalee picture swarnalee  ·  4Comments

jtr109 picture jtr109  ·  5Comments

maxdrohde picture maxdrohde  ·  3Comments