Closed jacobobryant closed 1 year ago
Hey Jacob, I'm looking into this one. I found this article from Netlify that says you need to add a 404.html
page to your build and it will be picked up automatically.
I tried adding a 404 page to the theme, but it renders as a 404 folder with an index.html file inside. Do you think the best way then is to make some special handling for rendering a 404 page, or do you think there's a different approach?
I just peeked at the code to refresh my memory, and it looks like the render!
function currently is hard-coded to always put a index.html
on the end: https://github.com/jacobobryant/platypub/blob/master/themes/default/src/com/platypub/themes/common.clj#L158
It'd probably be best to modify that function so e.g. if you put {"/404.html" ...}
in your pages
var, it'll render to that file instead of to /404.html/index.html
(which is what it does currently, right?). Biff does something like that for the :static-pages
feature: https://github.com/jacobobryant/biff/blob/master/src/com/biffweb/impl/rum.clj#L92
If we copied Biff's algorithm as-is (i.e. check to see if the path ends in a slash, and if so add a index.html
), that might introduce too breaking of a change--in platypub, currently if someone has "/foo"
as one of their paths, it gets rendered to "/foo/index.html"
, so it'd be nice to keep that behavior.*
How about change render!
so that it only adds an index.html
if the path doesn't already end in .html
?
*Realistically I think there's a total of like 3 people using platypub currently, but still nice to avoid breaking changes out of principle/habit...
I like it! So something like this for pages
,
(def pages
{"/" landing-page
"/archive/" archive-page
"/subscribe/" subscribe-page
"/404.html" not-found-page})
Would create index.html
, /archive/index.html
, /subscribe/index.html
, and 404.html
yep!
Currently you just get the default Netlify not found page, e.g. https://biffweb.com/no-page-here: