Not-found page
DocsNotFound is the view a reader gets for a docs URL that has no page. It keeps the site's layout, names the address that was asked for, and links back to the docs.
Using it
It goes in the else branch of Components/Pages/DocsPage.razor. shelldocs init writes it there for new sites.
@if (_document is not null)
{
<MarkdownContent Document="_document" />
}
else
{
<DocsNotFound />
}
A site created before 0.1.14-alpha has a hand-written block in that branch. Replace it with the tag.
What it does
| Prop | Type | Default | Description |
|---|---|---|---|
Answers HTTP 404 |
status |
— | A crawler or link checker sees a missing page as missing, not as a page that loaded. |
Names the address |
content |
— | Shows the path that was requested. |
Links back |
content |
— | To wherever /docs leads: the first docs page, in the latest version. |
In a static export
shelldocs build uses the same view in two ways.
It writes 404.html. The build requests a URL that doesn't exist and saves the response as 404.html at the root of the export. GitHub Pages, Cloudflare Pages, Netlify and most other static hosts serve that file, with a 404 status, for any URL that has no file. One file serves every unknown URL, so the build leaves the address out of it and shelldocs.js fills in the path the reader asked for, relative to the site's base. Before 0.1.17-alpha every unknown URL showed the build's own probe address.
It fails on a broken page. If a page from the navigation graph answers 404 or renders DocsNotFound, the build stops with an error instead of publishing a not-found page under a real URL. The usual cause is content that didn't reach the publish output.
With --spa-fallback, shelldocs build overwrites 404.html with a copy of the home page. A reader who follows a dead link then lands on the home page with no sign that the address was wrong. Leave the flag off unless you need it.
Changing the text
| Prop | Type | Default | Description |
|---|---|---|---|
Path |
string? |
the requested path |
The address shown in the message. |
HomeHref |
string? |
where /docs leads |
Where the link back goes. |
HomeLabel |
string |
Back to the docs |
Text of the link back. |
<DocsNotFound HomeHref="/docs/introduction" HomeLabel="Back to the introduction" />
DocsNotFound is for DocsPage.razor. It is not available as a tag in markdown.