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?
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 2 years ago · Edit answerI 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 2 years ago · Edit answer