Site Setting /
Missing Pages: Redirect or 404?
When a visitor opens a URL that doesn't exist, you have two options: redirect them to another page, or serve a “page not found” (404) page. Both avoid showing a raw error, but they mean very different things—and using the wrong one hurts your SEO and user experience.
This guide helps you tell them apart and shows the right way to handle each in Creght.
The Short Answer
A specific old URL has moved to a new URL → use a redirect.
The URL should never have existed (typos, deleted pages, guessed links) → return a 404 with a friendly not-found page.
Do NOT redirect every unknown URL to your homepage—search engines explicitly advise against it.
Redirect vs. 404: What's the Difference?
| Redirect | 404 Page | |
|---|---|---|
| Address bar URL | Changes (moves to new address) | Stays (remains on the original URL) |
| HTTP status code | 301 / 308 (permanent), 302 / 307 (temporary) | 404 |
| Meaning | “This content moved—go there instead” | “This content doesn't exist” |
| How search engines read it | Transfers ranking signals to the new URL | Knows the URL is invalid; drops it from the index |
| When to use | Known, one-to-one URL migrations | Any unknown / removed URL |
The key idea: a redirect is a “we moved” notice, a 404 is “no such page.” A random non-existent URL hasn't moved anywhere, so it shouldn't be redirected—it should honestly tell search engines and users that there's nothing here.
Three Common Scenarios
Scenario 1: Give visitors a friendly “not found” page
A visitor mistypes a URL or clicks a link to a page you've deleted. You want a page that isn't jarring—ideally with a link back home, a search box, or popular content.
Do this: build a custom 404 page. The URL stays the same, the status code is 404, and you fully control the page design. This is the right choice in the vast majority of cases.
Scenario 2: An old URL has moved to a new one
For example, you renamed /old-blog/hello to /posts/hello, and the old link is still referenced elsewhere, bookmarked, or indexed.
Do this: configure a redirect rule using a permanent (308) redirect from the old URL to the new one. Visitors and search engines are smoothly carried to the new address, and the old URL's accumulated SEO value transfers over.
Scenario 3: Send every unknown URL to the homepage
This looks “tidy,” but it's strongly discouraged.
For search engines: Google treats “content doesn't exist but returns 200 or redirects to the homepage” as a soft 404, which lowers your site quality signals. Google officially recommends returning a real 404 for non-existent pages.
For users: visitors end up on the homepage unexpectedly, confused, and still can't find what they were looking for.
The right approach: return a 404, and put a prominent “back to home” button on the 404 page. This satisfies search engines and respects your users.
How to Do It in Creght
1. Custom 404 page: create page/404.tsx
Add a page named 404 in your pages directory (page/404.tsx). From then on, any URL that doesn't match a route automatically renders this page and returns a 404 status code, keeping the visitor's original URL in the address bar.
// page/404.tsx
export default function NotFound() {
return (
<main style={{ textAlign: 'center', padding: '80px 20px' }}>
<h1>404</h1>
<p>Sorry, the page you're looking for doesn't exist.</p>
<a href="/">Back to home</a>
</main>
)
}Likewise, you can create page/500.tsx to customize the page shown when a server error occurs.
Tip: a 404 page works like any other page—you can use components, styling, and
getServerSideProps, e.g. to show recommended articles or a site search box.
2. Redirects: define redirects in talizen.config.ts
For known URL migrations, configure redirect rules in talizen.config.ts at your site root:
// talizen.config.ts
export default {
redirects: [
// Exact match: 308 permanent redirect
{ source: '/old-page', destination: '/new-page', permanent: true },
// Wildcard: migrate everything under /blog to /posts (307 temporary)
{ source: '/blog/*', destination: '/posts/*', permanent: false },
],
}permanent: truereturns 308 (permanent)—use it when content has truly moved for good and you want to transfer SEO value.permanent: falsereturns 307 (temporary)—use it for temporary redirects.sourcesupports exact matches and a trailing/*wildcard (the matched segments are back-filled into the*indestination).
Redirect rules take priority over page matching: a matched URL redirects immediately without rendering a page, so it never triggers a 404.
Quick Decision Guide
Did this URL once have content that has now moved? → Redirect (
redirectsintalizen.config.ts, use 308 for permanent).Should this URL never have existed? → 404 (custom
page/404.tsxwith a link back home).Not sure? → Default to 404. It's the safest, most SEO-friendly fallback.
