SEO
SEO reference
Every option of VitNode's seo server config and the withSeo server entry, with types, defaults, sitemap list source shapes and configuration errors.
This page lists the options of buildServerConfig({ seo }) and withSeo. To turn the feature on, follow Set up SEO.
seo options
Set in src/vitnode.server.config.ts. Read when the server starts.
Prop
Type
Leaving seo out is the same as seo: { indexing: true }. To serve your own robots.txt and sitemap, leave withSeo out of the server entry instead.
withSeo options
withSeo(entry, options) from @vitnode/core/tanstack/seo/server wraps the server entry, outside withPageCache. Server-only.
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
config | VitNodeServerConfig | Yes | - | The app's vitNodeServerConfig. seo, i18n and pageCache.storage are read from it. |
sitemap | SeoSitemapManifest | Yes | - | sitemapManifest from the generated src/sitemap-sources.gen.ts. |
sources | readonly SeoSitemapListSource[] | No | [] | App-owned URL lists, each published as /sitemap-{id}-{n}.xml. |
withSeo answers /robots.txt, /sitemap.xml, /sitemap-*.xml and POST /api/vitnode/content/revalidate itself, and passes every other request to entry.
SeoSitemapListSource
| Name | Type | Description |
|---|---|---|
id | string | The file stem: lowercase letters, digits and dashes. pages is reserved. |
urls | () => Promise<readonly SeoSitemapUrl[]> | readonly SeoSitemapUrl[] | Read once per server process and host. |
Each SeoSitemapUrl:
| Name | Type | Required | Description |
|---|---|---|---|
path | string | Yes | The canonical pathname, e.g. /docs/dev. |
origin | string | No | A configured origin. Defaults to the web origin; any other host is dropped. |
lastModified | Date | null | No | Leave it out when there is no reliable modification date. |
alternates | { locale, path, origin? }[] | No | One per language, locale may be x-default. |
Errors
An invalid seo value stops the server at startup with a SeoConfigError whose message starts with [VitNode SEO] and names the option:
| Message contains | Fix |
|---|---|
`seo.indexing` must be `true` or `false` | Pass a boolean, not a string such as "true". |
... is not an option. Use ... | Remove or rename the unknown key. |
seo.sitemap.paths entry "..." must be a path on this site | Start the path with a single /. |
... is under /admin or /api | Remove the path; those are never public pages. |
... starts with the locale "pl" | List the unlocalized path; every language is added for you. |
Related
- robots.txt: what the generated file contains.
- Sitemap: how each source is published.