redirects in website_config when an old URL should move before page matching begins.
Define a page route
Every page must directly default-exportdefinePage({ ... }) and contain one inline route string literal:
pages/post
:. A parameter name must start with a letter and can contain letters, numbers, _, or -.
Static segments can contain lowercase letters, numbers,
., _, ~, and -. Cactal does not support wildcards, catch-all parameters, optional segments, regular expressions, query strings, or hash fragments in route patterns.
Canonical route normalization
Cactal stores canonical routes in lowercase, without trailing slashes. The quality gate can rewrite a noncanonical literal such as/Blog/:Slug/ to /blog/:slug before publishing.
Requests are matched case-insensitively and without a trailing slash. A request whose path is not canonical receives a 301 redirect to the canonical path, with its query string preserved. Dynamic parameter values keep their original case.
Matching priority and ambiguity
Routes with more static segments win. A fully static route beats a parameterized route:/blog/:slug and /blog/:id match the same URLs. head/check reports every duplicate or ambiguous route it finds.
Reserved paths
Page routes and redirect sources cannot claim Cactal’s serving paths:/robots.txt/sitemap.xmland/sitemap-<n>.xml/_frameworkand anything below/_framework/
/favicon.ico is not reserved. A page or authored redirect for /favicon.ico takes precedence over the website favicon setting.
Link between pages
Use ordinary anchors for links within your website:--cactal-navigation-progress-color in your global CSS:
Read request parameters
Theparam reader is available in render:
pages/search
param.path(name) is type-checked against the page route and returns one string. param.query(name) returns a string, an array when the key is repeated, or undefined. The raw params and query maps contain the same values.
Use the query-time parameter helper to bind request values into CMS queries. See Build pages with CMS data.
Configure redirects
Add an inlineredirects array to the website_config singleton. metadata and redirects can coexist:
website_config
Redirects run before page matching and server rendering. The first matching rule wins, so put specific rules before broader parameterized rules:
/blog/special would redirect to /articles/special.
Redirect status codes
Browsers and search engines cache permanent redirects aggressively. Use
302 or 307 until you are certain a move is permanent.
Parameters and query strings
A target can reuse any parameter declared by its source:from fails validation. Parameter names cannot repeat within one pattern.
Incoming query strings are always preserved and appended to the target. Do not include a query string or hash in from or to:
Local and external targets
Local targets begin with/. External targets must be absolute http or https URLs without credentials, query strings, or hashes:
Validation and loop protection
head/check and publish reject:
- Empty paths, whitespace, repeated slashes, trailing slashes, query strings, and hashes
- Unsupported status codes
- Duplicate source patterns, including duplicates that differ only by case
- Self-redirects and local redirect loops, including loops through parameterized routes
- Target parameters absent from the source
- Redirects from reserved serving paths
- Unknown, computed, duplicate, or spread properties
redirects value must be an inline array of inline object literals. Variables, function calls, object spreads, array spreads, and computed keys are not statically extractable:
Edit redirects through the API
There is no partial redirects endpoint. Read the current head snapshot, update the completewebsite_config source, then upsert the singleton with PUT /v1/websiteSourceCode/files:
PATCH /v1/websiteSourceCode/metadata without a page edits only the metadata property and preserves redirects. Use it for semantic metadata changes, not redirect changes.
Publish and verify
Redirects are source-versioned. They appear on the draft host after its preview build is ready and reach production only after you publish the source version.Location header, including preserved query parameters. Then run head/check, publish, and repeat the request against the production hostname.
Troubleshooting
Next steps
- Build pages with CMS data for typed queries and render props
- Configure SEO metadata for canonical URLs and crawler metadata
- Edit source code for leases, snapshots, and file upserts
- Preview drafts and versions before publishing a redirect migration