Using the documentation I figured out how to create a custom 404 error page. That was easy. But I need more static error pages like 401 (unauthorised) and 403 (forbidden). I tried it the same way like I did it with the 404 error page and created a HTML file in the “layouts” directory, but it didn’t worked. Only the “404.html” file will be generated and copied to the “public” folder but nothing happened to the “401.html” and “403.html” files.
What can I do to generate these custom error pages?
Sorry for necromancy, but I have the same problem as @McPringle and I didn’t see the point of duplicating this thread, which I believe remains unsolved up to this day.
The workaround of putting other error pages in /static/ doesn’t work for me, because any page that I place there, is ignored by /layouts/_default/baseof.html. This means that after building the site, those error pages will be moved to /public/“as is” — without head, header, footer or whatever partial was defined in baseof.html.
As a last (and dirty) resort, I tried copy-pasting content of baseof.html file into /static/403.html and replacing main calls with custom error page HTML, but it seems that Hugo doesn’t parse commands enclosed in {{ }} for pages in /static/.
You are responding to a comment made 6 years ago and pointing to a GitHub issue that has been closed since 2017.
Instead of resurrecting old forum topics and commenting on closed GitHub issues, you need to open a new GitHub issue with your request, while referencing the previous closed issue and explaining why you need this feature.
You will not get attention the way you are approaching this, just as the poster above didn’t get a reply.
Also for future reference, please have a look at the updated forum rules over here.
Never understood the point of spawning duplicates for unsloved issues and confusing Google and other search engines with those, but okay, I can appreciate the rules.