Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

headTags config validation rejects boolean HTML attribute values #12233

Copy link
Copy link

Description

@DhineshPonnarasan
Issue body actions

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

The headTags configuration rejects boolean HTML attribute values during validation, despite three pieces of evidence showing this is unintentional:

  1. TypeScript types allow booleans@docusaurus/types defines attributes?: Partial<{[key: string]: string | boolean}>
  2. Renderer handles booleanspackages/docusaurus/src/server/htmlTags.ts:68-70 explicitly handles boolean attributes, rendering true as the attribute name alone and false as omitted
  3. Sibling scripts config accepts booleansconfigValidation.ts uses .unknown() which allows boolean values, and the docs say "you might want to add async: true/defer: true"

Reproducible demo

https://new.docusaurus.io — create a new project and add the headTags config shown below.

Steps to reproduce

  1. Create a fresh Docusaurus project:
npx create-docusaurus@3.10.1 my-repro classic --javascript
cd my-repro
  1. Add this to docusaurus.config.js:
const config = {
  headTags: [
    {
      tagName: 'script',
      attributes: {
        src: '/analytics.js',
        async: true,
      },
    },
  ],
  // ... rest of config
};
  1. Run:
npm run build

Expected behavior

The configuration should accept valid HTML boolean attributes such as async, defer, and disabled, consistent with the published TypeScript types and rendering behavior.

Actual behavior

Build fails with:

[ERROR] Error: "headTags[0].attributes.async" must be a string

The validation schema uses Joi.string() which restricts all attribute values to strings, contradicting the TypeScript type definition and the renderer's boolean handling.

Your environment

  • Docusaurus: 3.10.1 (npm release)
  • Node.js: v24.14.0
  • Package manager: npm
  • OS: Windows 11

Self-service

  • I'd be willing to fix this bug myself.
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAn error in the Docusaurus core causing instability or issues with its executionAn error in the Docusaurus core causing instability or issues with its executionstatus: needs triageThis issue has not been triaged by maintainersThis issue has not been triaged by maintainers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.