A sitemap is an XML file (typically /sitemap.xml) that lists all the pages on your site and helps search engines discover and index your content more efficiently. While not required, sitemaps are especially useful for:
Laioutr can use Nuxt Sitemap (part of Nuxt SEO) to automatically generate sitemaps based on your site's pages. Unlike robots.txt (which is included by default), sitemap is optional and needs to be added to your project.
Nuxt Sitemap automatically generates a sitemap.xml file based on your site's routes. For a Laioutr frontend, this means:
noindex in Studio are automatically excluded from the sitemapSo once configured, the sitemap stays up-to-date with your pages without manual maintenance.
To enable sitemap generation, add @nuxtjs/sitemap to your Nuxt modules:
// nuxt.config.ts
export default defineNuxtConfig({
modules: [
'@laioutr-core/frontend-core',
'@nuxtjs/sitemap', // Add this
// ... other modules
],
});
Then install the package:
pnpm add @nuxtjs/sitemap
# or
npm install @nuxtjs/sitemap
After installation, the module will automatically generate /sitemap.xml based on your site's routes.
The module works with zero configuration out of the box, but you can customize it in nuxt.config.ts:
// nuxt.config.ts
export default defineNuxtConfig({
sitemap: {
// Your site URL (required for absolute URLs in sitemap)
hostname: 'https://yourstore.com',
// Exclude specific routes from sitemap
exclude: ['/checkout/**', '/cart', '/account/**'],
// Or include only specific routes
// include: ['/products/**', '/categories/**'],
},
});
If you're using @nuxtjs/robots (which is included by default with frontend-core), Nuxt Sitemap automatically excludes pages marked as noindex from the sitemap. This means:
robots: 'noindex' set in Studio won't appear in the sitemapSo your sitemap and robots.txt stay in sync automatically.
For large sites, you can split the sitemap into multiple files:
// nuxt.config.ts
export default defineNuxtConfig({
sitemap: {
hostname: 'https://yourstore.com',
sitemaps: {
pages: {
include: ['/**'],
exclude: ['/products/**', '/categories/**'],
},
products: {
include: ['/products/**'],
},
categories: {
include: ['/categories/**'],
},
},
},
});
This generates /pages-sitemap.xml, /products-sitemap.xml, and /categories-sitemap.xml, plus a sitemap index at /sitemap.xml.
If you need to include URLs that aren't part of your Nuxt routes (e.g. from an API or database), you can use sitemap sources:
// nuxt.config.ts
export default defineNuxtConfig({
sitemap: {
hostname: 'https://yourstore.com',
sources: [
// Fetch URLs from an API endpoint
'/api/sitemap-urls',
// Or use a function
async () => {
const urls = await fetchUrlsFromYourBackend();
return urls.map(url => ({ loc: url, lastmod: new Date() }));
},
],
},
});
You can customize how each URL appears in the sitemap using route rules:
// nuxt.config.ts
export default defineNuxtConfig({
routeRules: {
'/products/**': {
sitemap: {
changefreq: 'daily',
priority: 0.8,
lastmod: new Date().toISOString(),
},
},
'/categories/**': {
sitemap: {
changefreq: 'weekly',
priority: 0.7,
},
},
},
});
To include images in your sitemap (for Google Image Search), enable image discovery:
// nuxt.config.ts
export default defineNuxtConfig({
sitemap: {
hostname: 'https://yourstore.com',
// Automatically discover images from pages
discoverImages: true,
},
});
Since Laioutr pages are defined in the runtime config (RC) and registered as routes, Nuxt Sitemap automatically discovers them. Each page from your RC becomes an entry in the sitemap with:
updatedAt timestamp from RCrobots: 'noindex' in Studio, it's excludedWhen editors set robots directives in Studio (page variant SEO → robots), those settings affect the sitemap:
noindex are excluded from the sitemapindex (or no robots setting) are included in the sitemapSo editors can control both indexing and sitemap inclusion from the same place.
If your frontend uses @nuxtjs/i18n (which frontend-core includes), Nuxt Sitemap automatically includes all language variants of each page in the sitemap, with proper hreflang tags.
/sitemap.xml based on your Laioutr pages (from runtime config).noindex in Studio are automatically excluded.For detailed configuration options and advanced usage, see the Nuxt Sitemap documentation.