Skip to content

Add default 404 page to sbt-typelevel-site#871

Open
abby-ql wants to merge 8 commits intotypelevel:mainfrom
abby-ql:html-injection
Open

Add default 404 page to sbt-typelevel-site#871
abby-ql wants to merge 8 commits intotypelevel:mainfrom
abby-ql:html-injection

Conversation

@abby-ql
Copy link

@abby-ql abby-ql commented Feb 24, 2026

This PR closes issue #217
-adds a default 404.html page to sbt-typelevel-site injected at the theme level so that all sites using the plugin automatically receive a 404 page by default
-page added programmatically via ThemeBuilder.addInputs, similar to how the API forwarder page is injected
-allow users to override it by providing their own docs/404.md or docs/404.html
-the default 404 page keeps the Helium style & allow click to go back to homepage(index.html)

Manual testing done to:
-verify 404.html is generated when no user defined 404 exists
-confirm a user-provided docs/404.md overrides the default
-checked correct behavior in tlSitePreview and in generated static output

Before:
image
Now:
image
(I initially explored an alternative approach where a default 404.md was written into mdocOut so that Laika would render it through Helium and apply full layout styling. This worked visually, but the 404 page appeared in the sidebar and it requires additional task wiring so I gave up on that approach)

@mergify mergify bot added the site label Feb 24, 2026
@armanbilge
Copy link
Member

@abby-ql thanks for the PR! before I review, would you mind making a contribution to our onboarding repo? There are instructions in the README. Thank you!

https://github.com/typelevel/gsoc-onboarding

@abby-ql
Copy link
Author

abby-ql commented Feb 27, 2026

sure @armanbilge i have just made a PR to the onboarding repo, thank you!

@armanbilge
Copy link
Member

(I initially explored an alternative approach where a default 404.md was written into mdocOut so that Laika would render it through Helium and apply full layout styling. This worked visually, but the 404 page appeared in the sidebar and it requires additional task wiring so I gave up on that approach

@abby-ql thanks for mentioning this! I actually think this approach sounds interesting, and maybe we can debug some of the problems you encountered. Would you mind opening an alternative PR that tries this, so I can help you work through it?

For example, instead of writing to mdocOut with a task (is this what you did?) you can just add the 404.md to the Laika virtual file tree.

@abby-ql
Copy link
Author

abby-ql commented Feb 28, 2026

@armanbilge Thank you so much for the feedback! Yep, the task approach was exactly what I did in my earlier experiment. I defined a custom ensureDefault404 task that runs after mdoc and writes a 404.md file into mdocOut if one doesn’t already exist. It is between mdoc and laikaSite so that Laika would render it through Helium and apply the normal layout.

Following your suggestion I’ll open an alternative PR that try adding the default 404.md directly to laika’s virtual input tree at the build level:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants