Redirect All Errors to Archives Page?

I'd like any 404s to send visitors to my Archives page where they could search or scan through any posts to find what they were looking for. I noticed this question that looked to achieve something similar, but (ironically enough) that page itself errors out.

Is there a way to make this work?

3 replies

I will work out why that page won't load – thank you for bringing it to my attention.

You'll want to add some JS to your template's error page (error.html) which performs the redirect. There's a good guide to redirecting with JS on Stack Overflow.

Answered 4 months ago · Improve this answer

I ended up solving this a different way by embedding the Archives page content within the error.html page. I first had to separate out the html content (search box, popular tags, post list) into its own archivesContent.html document. Then I "called" it with

{{> archivesContent}}

in both the archives.html and error.html pages.

That way I could customize the text at the top of the error page to acknowledge that the URL didn't exist, but still offer something more helpful to the visitor.

You can check out my example here.

Answered 4 months ago · Improve this answer

Great, looks good!

Answered 4 months ago · Improve this answer

Markdown allowed
Question or feedback?
Contact us


developers 28 questions bug 14 questions posts 9 questions resolved 7 questions request 6 questions google-drive 5 questions configure 4 questions pages 3 questions added 3 questions meta 3 questions More tags →
Subscribe for changes
RSS Feed of latest questions