Skip to content
MagiCMS

Routing

Default language

The default language lives at /. Pages are rendered by src/pages/index.astro (home) and src/pages/[slug].astro (everything else). homeSlug in site.config.json is the page slug that maps to / — by convention an empty string means the page literally named index in the CMS.

Multi-language

Non-default languages are routed at /<lang>/.... Templates live in src/lang/[lang]/:

  • index.astro — home in non-default language.
  • [slug].astro — CMS pages in non-default language.
  • [slug]/page/[page].astro — paginated pages.
  • [collection]/[slug].astro — collection detail in non-default language.

Astro.currentLocale is the canonical locale resolver. Always default to siteConfig.languages[0] when currentLocale is undefined. Use langPrefix for all internal links — never include the default language in the URL.

Paginated pages

src/pages/[slug]/page/[page].astro paginates a list block (or any block with perPage set) on the page. The block's perPage field determines pages per page; paginationPageParam is the URL param (default page); maxPaginationPages caps the URL space.

The <Pagination> component renders prev/next buttons based on navigation order.

Collection detail

src/pages/[collection]/[slug].astro is auto-generated for every collection. The collection name is the first URL segment, the entry slug is the second. Custom collection routes are not allowed — extend the scaffold template instead.

Sitemap & robots

src/pages/sitemap.xml.ts and src/pages/sitemap-index.xml.ts use collectSitemapUrls() to enumerate every page and collection entry across all configured languages. src/pages/robots.txt.ts writes a sitemap-aware robots.txt that disallows preview environments.

Vi bruker cookies for å forbedre din opplevelse.