nuxt-modules / robots

Tame the robots crawling and indexing your Nuxt site.
https://nuxtseo.com/robots
412 stars 30 forks source link

Robots package prevents pages from being generated #123

Closed SvanThuijl closed 2 months ago

SvanThuijl commented 3 months ago

When I run nuxt generate my pages are not being generated. I have a bunch of pages in the pages directory. When I disable robots and sitemap the pages are being generated as expected. Also when running nuxt dev everything works as expected.

The console output when running nuxt generate with robots enables is the following:

✔ Server built in 1171ms                                                                                                                                                           11:02:15 PM
ℹ Initializing prerenderer                                                                                                                                                   nitro 11:02:15 PM
ℹ Prerendering 4 initial routes with crawler                                                                                                                                 nitro 11:02:17 PM
  ├─ /robots.txt (10ms)                                                                                                                                                       nitro 11:02:17 PM
  ├─ /__sitemap__/style.xsl (7ms)                                                                                                                                             nitro 11:02:17 PM
  ├─ /200.html (19ms)                                                                                                                                                         nitro 11:02:17 PM
  ├─ /404.html (19ms)                                                                                                                                                         nitro 11:02:17 PM
  ├─ /sitemap.xml (6ms)                                                                                                                                                       nitro 11:02:19 PM
ℹ Prerendered 5 routes in 3.433 seconds                                                                                                                                      nitro 11:02:19 PM
✔ Generated public .output/public

package.json

{
    "name": "nuxt-app",
    "private": true,
    "engines": {
        "node": "22.x"
    },
    "type": "module",
    "scripts": {
        "build": "nuxt build",
        "dev": "nuxt dev",
        "format": "prettier --write .",
        "generate": "nuxt generate && node scripts/post-process.js",
        "preview": "nuxt preview",
        "postinstall": "nuxt prepare"
    },
    "dependencies": {
        "@nuxt/image": "^1.7.0",
        "@nuxtjs/dotenv": "^1.4.2",
        "@nuxtjs/seo": "^2.0.0-rc.10",
        "@nuxtjs/tailwindcss": "^6.12.0",
        "html-minifier": "^4.0.0",
        "html-validate": "^8.20.1",
        "jsdom": "^24.1.0",
        "nuxt": "^3.12.1",
        "nuxt-icon": "^0.6.10",
        "nuxt-jsonld": "^2.0.8",
        "tailwindcss-palette-generator": "^0.6.5",
        "vue": "^3.4.27",
        "vue-router": "^4.3.2"
    },
    "devDependencies": {
        "eslint-config-prettier": "^9.1.0",
        "eslint-plugin-prettier": "^5.1.3",
        "prettier": "^3.3.2",
        "prettier-plugin-organize-attributes": "^1.0.0",
        "prettier-plugin-tailwindcss": "^0.6.2"
    }
}

nuxt.config.ts

export default defineNuxtConfig({
    app: {
        head: {
            charset: 'utf-8',
            htmlAttrs: {
                lang: site.locale
            },
            title: site.name,
            viewport: 'width=device-width, initial-scale=1'
        }
    },
    devtools: {
        enabled: true
    },
    features: {
        noScripts: true
    },
    image: {
        format: ['webp', 'avif', 'png'],
        densities: [1, 2],
        quality: 70
    },
    modules: [
        '@nuxt/image',
        '@nuxtjs/seo',
        '@nuxtjs/tailwindcss',
        'nuxt-icon',
        'nuxt-jsonld'
    ],
    runtimeConfig: {
        public: {
            siteEnv: process.env.NUXT_SITE_ENV
        }
    },
    site: {
        url: site.url,
        description: site.description,
        defaultLocale: site.locale
    },
    webpack: {
        extractCSS: true
    },

    ogImage: {
        enabled: true
    },
    sitemap: {
        enabled: true
    },
    robots: {
        enabled: true
    },
    seoExperiments: {
        enabled: true
    },
    schemaOrg: {
        enabled: false
    },
    linkChecker: {
        enabled: true
    }
})

Interestingly the pages do show up in the robots.txt

<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="/__sitemap__/style.xsl"?>
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd http://www.google.com/schemas/sitemap-image/1.1 http://www.google.com/schemas/sitemap-image/1.1/sitemap-image.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    <url>
        <loc>https://localhost:3000/</loc>
    </url>
    <url>
        <loc>https://localhost:3000/n00b</loc>
    </url>
    <url>
        <loc>https://localhost:3000/test</loc>
    </url>
</urlset>
<!-- XML Sitemap generated by @nuxtjs/sitemap v5.2.0 at 2024-06-14T03:13:51.892Z -->
uke5tar commented 3 months ago

+1

harlan-zw commented 2 months ago

This seems to be from Nuxt SEO, nuxt-simple-robots has recently been migrated into this module though. Can you confirm if it's still an issue with latest versions.

SvanThuijl commented 3 weeks ago

Sorry for not getting back to this earlier. The issue is resolved with the latest versions.