Skip to content

Metadata robots noindex causes build error #7772

@chernodub

Description

@chernodub

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

Faced error when tried to build the application with metadata: [{name: 'robots', content: 'noindex'}] set in docusaurus.config.js. This is a recommended way of hiding the website from search crawlers. I was also able to avoid the issue by using an alternative way of applying noindex in metadata.

Reproducible demo

https://github.com/chernodub/docusaurus-build-issue-repro

Steps to reproduce

With attached demo:

  1. Clone the repo
  2. npm install
  3. npm run build

With clean docusaurus build:

  1. npx create-docusaurus@latest my-website classic
  2. cd my-website
  3. Add metadata: [{name: 'robots', content: 'noindex'}] to docusaurus.config.js
  4. npm run build

Expected behavior

npm run build finishes without errors

Actual behavior

npm run build fails with an error

node:events:505
      throw er; // Unhandled 'error' event
      ^

EmptySitemap: You ended the stream without writing anything.
Emitted 'error' event on SitemapStream instance at:
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)

Your environment

  • Docusaurus version used: 2.0.0-beta.22
  • Environment name and version (e.g. Chrome 89, Node.js 16.4): Node.js 16.6.0
  • Operating system and version (e.g. Ubuntu 20.04.2 LTS): macOS Monterey 12.4

Self-service

  • I'd be willing to fix this bug myself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAn error in the Docusaurus core causing instability or issues with its execution

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions