Closed thescientist13 closed 2 years ago
Not sure what others think, but I think if Greenwood wants to provide a default 404 page, it should be as part of a plugin, e.g. #200
@hutchgrant Can you provide a brief write up of what you think this feature should do and what user would / should expect from it? That can help us drive the addition of this feature.
No I don't think 404 should be a plugin. It needs to be included by default and plugins can be made to change those default settings. Can you imagine installing wordpress, drupal, or gatsby and then needed a plugin just for a 404 page, not necessarily just adding a theme page etc? Every modern CMS and many static site generator provides 404s by default.
https://www.gatsbyjs.org/docs/add-404-page/
The easiest method to do this is using our markdown loader, which enables the use of page templates, to easily theme and write a 404 page. We simply include a 404.md
within the core /src/templates
folder, which can easily be overridden from the user's workspace e.g. /src/pages/404.md
. We add it to the graph so it's serialized along with every other page. Then we add a postSerialize function to copy the file to the 404.html in the root of our build(public
) folder.
I agree that the 404 page should be included by default and easily customizable and placed in a folder that would be logical for the user (such as /pages or /templates).
The primary issue that I see maybe coming up from this is if the final rendered site is deployed from a service that does not handle a 404.html page like Netlify... is there a fallback or way to inform the user to handle 404s is a different way? Maybe this is not even an issue (my ignorance).
Taking a beat and documenting this feature first does seem like a good way of approaching it with a clear and thought out plan (and probably good practice in general). I kind of use a similar technique with photography called 'previsualization' where you start by imagining the desired finish image and then start to break down how to achieve it, what techniques, equipment, modifications would be needed and how they would be used to reach the end goal.
I can see the super charged 'smart' 404 being a plugin - a cool feature that some people may want but is probably not for everyone.
Ok, let's proceed with this then, and I will close #176 / #225 as this isn't really a bug, just an undeveloped / undocumented feature.
Let's keep the Greenwood 404.md we bundle simple and treat it like a page, leveraging whatever the default page-template.js is. We can then use a plugin down the road to provide a more super powered option of handling 404s. (like with a search feature).
Defer to #200
Can incorporate these thoughts re: 404 as a plugin
As part of #669 and its outstanding TODO around server command based testing, it would be good to ensure we cover as much 404 specific route handling as we can when we work on this.
Also would be good to keep this in line with needs around default workspace vs node_modules route handling, as being discussed in https://github.com/ProjectEvergreen/greenwood/discussions/691.
Type of Change
Summary
Per conversations coming out of https://github.com/ProjectEvergreen/greenwood/pull/225#pullrequestreview-305581464, it seems that there is a greater conversation to be had around the expectations of what a 404 page should be for Greenwood, so tracking that as a top level item in its own issues.
Details
Some questions around the feature to be answered are:
In general, common behavior would / could be: