jupiteror
jupiteror

Reputation: 1205

Custom Jekyll 404 page is not working on Heroku

I have a Jekyll site deployed to Heroku. I have created a custom 404 error page in source/404.html file. The page can be found at mydomain.com/404/. But when I try to go to pages which don't exist, the custom 404 page doesn't work. And instead I get a blank, default Heroku error page.

What can be a reason for that? Note that a permalink for the page doesn't have an html extension. Can this be a problem?

Upvotes: 4

Views: 1446

Answers (2)

Ivan Gabriele
Ivan Gabriele

Reputation: 6900

If you have followed the Heroku official Jekyll setup, you should use 2 buildpacks :

The latter allow a static.json configuration file (at the root of your project) to customize nginx. The documentation tells you how to add custom error pages.

In your case, the static.json file should contain :

{
  ...
  "error_page": "404.html",
  ...
}

Upvotes: 0

Alan
Alan

Reputation: 479

Have you tried adding a permalink to the YAML front matter?

permalink: /404.html 

also I have read that the 404 page is specific to GitHub pages, but worth a try

Upvotes: 2

Related Questions