{"record":{"id":"7b5b47da7445cd6d","repo":"facebook/docusaurus","slug":"the-gtag-field-in-themeconfig-should-now-be-spec-7b5b47","errorCode":null,"errorMessage":"The \"gtag\" field in themeConfig should now be specified as option for plugin-google-gtag. For preset-classic, simply move themeConfig.gtag to preset options. 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\\. For preset-classic, simply move themeConfig\\.gtag to preset options\\. More information at https://github\\.com/facebook/docusaurus/pull/5832\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/docusaurus-preset-classic/src/index.ts","lineNumber":53,"sourceCode":"    debug,\n    docs,\n    blog,\n    pages,\n    sitemap,\n    svgr,\n    theme,\n    gtag,\n    googleTagManager,\n    ...rest\n  } = opts;\n\n  const themes: PluginConfig[] = [];\n  themes.push(makePluginConfig('@docusaurus/theme-classic', theme));\n  if (algolia) {\n    themes.push(require.resolve('@docusaurus/theme-search-algolia'));\n  }\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. For preset-classic, simply move themeConfig.gtag to preset options. More information at https://github.com/facebook/docusaurus/pull/5832.',\n    );\n  }\n\n  // TODO Docusaurus v5: remove\n  if ('googleAnalytics' in opts || 'googleAnalytics' in themeConfig) {\n    throw new Error(\n      `In Docusaurus v4, the Google Analytics plugin has been removed.\nYou can now use either:\n- @docusaurus/plugin-google-gtag - presetOptions.gtag\n- @docusaurus/plugin-google-tag-manager - presetOptions.googleTagManager\n\nSee also: https://github.com/facebook/docusaurus/issues/7221`,\n    );\n  }\n\n  const plugins: PluginConfig[] = [];\n","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/facebook/docusaurus/blob/3f483e80e326cc646b54b83d564b3f0c4881b9a6/packages/docusaurus-preset-classic/src/index.ts#L35-L71","documentation":"Thrown by the preset-classic function when a 'gtag' key exists in themeConfig. It is the preset-level counterpart of the plugin's own guard: preset-classic detects the legacy themeConfig.gtag location and instructs the user to move it to preset options. This runs before plugins are constructed so users get an actionable message early.","triggerScenarios":"Configuring themeConfig: { gtag: {...} } while using @docusaurus/preset-classic.","commonSituations":"Upgrading from a Docusaurus version where gtag was configured under themeConfig; outdated docs/tutorials; partial migration.","solutions":["Move the gtag config from themeConfig into the preset options: presets: [['classic', { gtag: {...} }]].","Remove themeConfig.gtag entirely.","Rebuild."],"exampleFix":"// before\npresets: [['classic', {}]],\nthemeConfig: { gtag: { trackingID: 'G-XXX' } }\n// after\npresets: [['classic', { gtag: { trackingID: 'G-XXX' } }]],","handlingStrategy":"validation","validationCode":"if ('gtag' in siteConfig.themeConfig) {\n  throw new Error('Move themeConfig.gtag to preset options (presets classic.gtag)');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Centralize analytics config under preset options, not themeConfig.","After upgrades, grep docusaurus.config for relocated keys."],"tags":["gtag","preset-classic","theme-config","migration"],"backgroundTag":null,"analyzedSha":"3f483e80e326cc646b54b83d564b3f0c4881b9a6","analyzedAt":"2026-08-12T13:25:04.382Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}