Fixed missing 404 for non-existent pages

This commit is contained in:
John Wellbelove 2026-06-02 13:06:53 +01:00
parent 6cba6073f1
commit 0704961e8c
3 changed files with 28 additions and 0 deletions

View File

@ -2,6 +2,7 @@ baseURL = 'http://localhost/'
#baseURL = 'https://www.etlcpp.com/hugo/'
languageCode = 'en-gb'
title = 'Embedded Template Library'
includeFiles = [".htaccess"]
[markup]
[markup.highlight]

20
hugo/layouts/404.html Normal file
View File

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Page Not Found</title>
<style>
body { text-align: center; font-family: sans-serif; padding: 100px 20px; background: #f9f9f9; color: #333; }
h1 { font-size: 48px; margin-bottom: 10px; }
p { font-size: 18px; color: #666; margin-bottom: 30px; }
a { display: inline-block; padding: 10px 20px; background: #0056b3; color: white; text-decoration: none; border-radius: 5px; }
a:hover { background: #004085; }
</style>
</head>
<body>
<h1>404</h1>
<p>Sorry, the page you are looking for doesn't exist.</p>
<a href="{{ site.BaseURL | default "/" }}">Return to Homepage</a>
</body>
</html>

7
hugo/static/.htaccess Normal file
View File

@ -0,0 +1,7 @@
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /404.html [L]
ErrorDocument 404 /404.html