pickstack

Nuxt + SEO

Meta/OG tags, canonical URL, JSON-LD, robots.txt and sitemap.xml. This page shows exactly what pickstack adds to a Nuxt project for SEO: the packages, the new files and the changes to existing ones. Every combination is installed, built, linted and tested in CI.

$ npm create pickstack@latest my-app -- --framework nuxt --modules seo --yes
Customize in the configurator

New files

server/routes/robots.txt.ts
export default defineEventHandler((event) => {
  const { siteUrl } = useRuntimeConfig(event).public;
  setHeader(event, "Content-Type", "text/plain; charset=utf-8");
  return `User-agent: *
Allow: /

Sitemap: ${siteUrl}/sitemap.xml
`;
});
server/routes/sitemap.xml.ts
export default defineEventHandler((event) => {
  const { siteUrl } = useRuntimeConfig(event).public;
  setHeader(event, "Content-Type", "application/xml; charset=utf-8");
  return `<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>${siteUrl}/</loc>
  </url>
  <url>
    <loc>${siteUrl}/about</loc>
  </url>
</urlset>
`;
});

Changes to existing files

app/app.vue (changed)
+<script setup lang="ts">+const { siteUrl } = useRuntimeConfig().public;+const route = useRoute();+ +useHead({+  link: [{ rel: "canonical", href: () => `${siteUrl}${route.path}` }],+  script: [+    {+      type: "application/ld+json",+      innerHTML: JSON.stringify({+        "@context": "https://schema.org",+        "@type": "WebSite",+        name: "my-app",+        url: siteUrl,+      }),+    },+  ],+});+ +useSeoMeta({+  description: "my-app: a web app.",+  ogType: "website",+  ogSiteName: "my-app",+  ogUrl: () => `${siteUrl}${route.path}`,+  twitterCard: "summary",+});+</script>+  <template>   <NuxtRouteAnnouncer />   <main class="app">⋯ 8 unchanged lines
app/pages/about.vue (changed)
+<script setup lang="ts">+useSeoMeta({ title: "About" });+</script>+  <template>   <section class="page">     <h1 class="title">About</h1>+    <p class="text">Built with Nuxt 4, Vue 3, TypeScript, SEO.</p>−    <p class="text">Built with Nuxt 4, Vue 3, TypeScript.</p>   </section> </template>  
app/pages/index.vue (changed)
+<script setup lang="ts">+useSeoMeta({ title: "Home" });+</script>+  <template>   <section class="page">     <h1 class="title">my-app</h1>⋯ 4 unchanged lines
nuxt.config.ts (changed)
⋯ 2 unchanged lines   compatibilityDate: "2025-07-15",   devtools: { enabled: true },   css: ["~/assets/css/main.css"],+  app: { head: { htmlAttrs: { lang: "en" }, titleTemplate: "%s | my-app" } },+  runtimeConfig: { public: { siteUrl: "https://example.com" } },+  nitro: { prerender: { routes: ["/robots.txt", "/sitemap.xml"] } }, });  

Project files

Related templates