{"record":{"id":"c918d6fb3839fbc2","repo":"facebook/docusaurus","slug":"the-gtag-field-in-themeconfig-should-now-be-spec","errorCode":null,"errorMessage":"The \"gtag\" field in themeConfig should now be specified as option for plugin-google-gtag. More information at https://github.com/facebook/docusaurus/pull/5832.","messagePattern":"The \"gtag\" field in themeConfig should now be specified as option for plugin-google-gtag\\. More information at https://github\\.com/facebook/docusaurus/pull/5832\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/docusaurus-plugin-google-gtag/src/options.ts","lineNumber":56,"sourceCode":"      }),\n      Joi.array().items(Joi.string().required()),\n    )\n    .required(),\n  anonymizeIP: Joi.boolean().default(DEFAULT_OPTIONS.anonymizeIP),\n});\n\nexport function validateOptions({\n  validate,\n  options,\n}: OptionValidationContext<Options, PluginOptions>): PluginOptions {\n  return validate(pluginOptionsSchema, options);\n}\n\nexport function validateThemeConfig({\n  themeConfig,\n}: ThemeConfigValidationContext<ThemeConfig>): ThemeConfig {\n  if ('gtag' in themeConfig) {\n    throw new Error(\n      'The \"gtag\" field in themeConfig should now be specified as option for plugin-google-gtag. More information at https://github.com/facebook/docusaurus/pull/5832.',\n    );\n  }\n  return themeConfig;\n}\n","sourceCodeStart":38,"sourceCodeEnd":62,"githubUrl":"https://github.com/facebook/docusaurus/blob/3f483e80e326cc646b54b83d564b3f0c4881b9a6/packages/docusaurus-plugin-google-gtag/src/options.ts#L38-L62","documentation":"Thrown by validateThemeConfig in plugin-google-gtag when a 'gtag' key is present in docusaurus.config themeConfig. The gtag configuration was moved out of themeConfig into the plugin's own options, so this guard rejects the old location and points to the migration PR. It fires during theme-config validation at startup.","triggerScenarios":"Having themeConfig: { gtag: {...} } in docusaurus.config.js while also using @docusaurus/plugin-google-gtag.","commonSituations":"Upgrading from an older Docusaurus where gtag lived in themeConfig; following an outdated tutorial; partial migration that left the key behind.","solutions":["Remove themeConfig.gtag and pass the same config (trackingID etc.) to the plugin in the plugins array or preset options.","For preset-classic, move it to the preset's gtag option.","Rebuild to confirm the error is gone."],"exampleFix":"// before\nthemeConfig: { gtag: { trackingID: 'G-XXX' } }\n// after\nplugins: [\n  ['@docusaurus/plugin-google-gtag', { trackingID: 'G-XXX' }],\n]","handlingStrategy":"validation","validationCode":"if ('gtag' in siteConfig.themeConfig) {\n  throw new Error('Move themeConfig.gtag to plugin-google-gtag options');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["After upgrading Docusaurus, search the config for legacy themeConfig keys (gtag, googleAnalytics).","Keep analytics config under the owning plugin's options, not themeConfig."],"tags":["gtag","analytics","theme-config","migration"],"backgroundTag":null,"analyzedSha":"3f483e80e326cc646b54b83d564b3f0c4881b9a6","analyzedAt":"2026-08-12T13:25:04.382Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}