Skip to Content
Documentation

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.

NameTypeRequiredDefaultDescription
configVitNodeServerConfigYes-The app's vitNodeServerConfig. seo, i18n and pageCache.storage are read from it.
sitemapSeoSitemapManifestYes-sitemapManifest from the generated src/sitemap-sources.gen.ts.
sourcesreadonly 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

NameTypeDescription
idstringThe 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:

NameTypeRequiredDescription
pathstringYesThe canonical pathname, e.g. /docs/dev.
originstringNoA configured origin. Defaults to the web origin; any other host is dropped.
lastModifiedDate | nullNoLeave it out when there is no reliable modification date.
alternates{ locale, path, origin? }[]NoOne 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 containsFix
`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 siteStart the path with a single /.
... is under /admin or /apiRemove the path; those are never public pages.
... starts with the locale "pl"List the unlocalized path; every language is added for you.
  • robots.txt: what the generated file contains.
  • Sitemap: how each source is published.