Closed chelsea-codes closed 1 year ago
I agree. Pull requests are welcome!
Is it even possible to add this feature? If I am not mistaken, this is something handled by the web-server.
The webserver can be configured to show a specific page on a 404 error, but by default it typically redirects to a 404.html
page at the root if such a page exists. The requested feature is to implement such a custom 404 page.
hexo new page 404
and add some text:
---
title: 404
date: 2022-06-27 19:57:51
---
Cannot find the page you are searching for.
2. In order to add styling I need to add an `*.ejs`-file, lets say I named it `notfound.ejs`, because I am afraid `404.ejs` will cause issues. I am going to rename it to `404.ejs` at the end, if possible.
3. Since, the 404 page is of type page I need to add the processing step the [`page.ejs`](https://github.com/probberechts/hexo-theme-cactus/blob/master/layout/page.ejs):
```ejs
<article class="post" itemscope itemtype="http://schema.org/BlogPosting">
<%- partial('_partial/post/gallery') %>
<div class="content" itemprop="articleBody">
<% if (page.notfound) { %>
<%- partial('_partial/notfound') %>
<% } else if (page.search || page.type === "search") { %>
<%- partial('_partial/search') %>
<% } else if (page.type === "tags") { %>
... and so on
notfound.ejs
to compile 404.md
to 404.html
?I am aware that the 404 page is being generated as index.html
inside a 404
-directory at the moment. This is something, I need to resolve too. Maybe my whole approach does not work, because the goal is to have the 404 in the root directory.
@metters You can use Hexo Generator to register a route for /404.html
.
Also, I added 404-page-generating support in this PR #330, and you can merge this PR to have a try.
Thanks!
I tried and my screen stays white when I do a local hexo server
.
Probably a mistake on my side, I am going to try again sometime this weekend.
You may check the hexo_project/public
folder after running hexo generate
. It should generate a 404.html
there.
i believe this issue can be closed.
It would be nice to have 404's handled with a page out-of-the-box - or maybe have it be optional.
Thanks for the theme!
Chelsea