Repository navigation
Closed
Labels
bugAn error in the Docusaurus core causing instability or issues with its executionstatus: needs triageThis issue has not been triaged by maintainers
Description
Have you read the Contributing Guidelines on issues?
- I have read the Contributing Guidelines on issues.
Prerequisites
- I'm using the latest version of Docusaurus.
- I have tried the
npm run clearoryarn clearcommand. - I have tried
rm -rf node_modules yarn.lock package-lock.jsonand 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:
- TypeScript types allow booleans —
@docusaurus/typesdefinesattributes?: Partial<{[key: string]: string | boolean}> - Renderer handles booleans —
packages/docusaurus/src/server/htmlTags.ts:68-70explicitly handles boolean attributes, renderingtrueas the attribute name alone andfalseas omitted - Sibling
scriptsconfig accepts booleans —configValidation.tsuses.unknown()which allows boolean values, and the docs say "you might want to addasync: true/defer: true"
Reproducible demo
https://new.docusaurus.io — create a new project and add the headTags config shown below.
Steps to reproduce
- Create a fresh Docusaurus project:
npx [email protected] my-repro classic --javascript
cd my-repro- Add this to
docusaurus.config.js:
const config = {
headTags: [
{
tagName: 'script',
attributes: {
src: '/analytics.js',
async: true,
},
},
],
// ... rest of config
};- Run:
npm run buildExpected 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.
Reacted by Aaron Thomas
Metadata
Metadata
Assignees
Labels
bugAn error in the Docusaurus core causing instability or issues with its executionstatus: needs triageThis issue has not been triaged by maintainers
Activity
ATKasem commentedon Jul 7, 2026
Hello! 👋 @DhineshPonnarasan
I’m going to move forward with a small PR for this.
The change will be narrowly scoped to updating
headTags.attributesvalidation so it acceptsstring | boolean, matching the existingHtmlTagObjecttype and renderer behavior. I’ll also add focused validation test coverage.This won’t broaden the schema to arbitrary attribute values; unsupported attribute value types will still be rejected.
ATKasem commentedon Jul 7, 2026
Opened a focused PR for this: #12237
The change is limited to allowing
headTags.attributesvalues to bestring | boolean, matching the existing public type and renderer behavior, with focused validation coverage.