{"record":{"id":"b702fa001ca32ae0","repo":"withastro/astro","slug":"several-font-families-have-been-registered-for-the","errorCode":null,"errorMessage":"Several font families have been registered for the ${bold(family.cssVariable)} cssVariable but they do not share the same name and provider.","messagePattern":"Several font families have been registered for the (.+?) cssVariable but they do not share the same name and provider\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/astro/src/assets/fonts/core/get-or-create-font-family-assets.ts","lineNumber":23,"sourceCode":"\tfontFamilyAssetsByUniqueKey,\n\tlogger,\n\tbold,\n\tfamily,\n}: {\n\tfontFamilyAssetsByUniqueKey: FontFamilyAssetsByUniqueKey;\n\tlogger: AstroLogger;\n\tbold: (input: string) => string;\n\tfamily: ResolvedFontFamily;\n}) {\n\tconst key = `${family.cssVariable}:${family.name}:${family.provider.name}`;\n\tlet fontAssets = fontFamilyAssetsByUniqueKey.get(key);\n\tif (!fontAssets) {\n\t\tif (\n\t\t\tArray.from(fontFamilyAssetsByUniqueKey.keys()).find((k) =>\n\t\t\t\tk.startsWith(`${family.cssVariable}:`),\n\t\t\t)\n\t\t) {\n\t\t\tlogger.warn(\n\t\t\t\t'assets',\n\t\t\t\t`Several font families have been registered for the ${bold(family.cssVariable)} cssVariable but they do not share the same name and provider.`,\n\t\t\t);\n\t\t\tlogger.warn(\n\t\t\t\t'assets',\n\t\t\t\t'These families will not be merged together. The last occurrence will override previous families for this cssVariable. Review your Astro configuration.',\n\t\t\t);\n\t\t}\n\t\tfontAssets = {\n\t\t\tfamily,\n\t\t\tfonts: [],\n\t\t\tcollectedFontsForMetricsByUniqueKey: new Map(),\n\t\t\tpreloads: [],\n\t\t};\n\t\tfontFamilyAssetsByUniqueKey.set(key, fontAssets);\n\t}\n\treturn fontAssets;\n}","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/withastro/astro/blob/52e6c34790cc8ac4e69e6135ace06049867e5c4a/packages/astro/src/assets/fonts/core/get-or-create-font-family-assets.ts#L5-L41","documentation":"Astro keys resolved font families by cssVariable + name + provider. When a new family reuses a cssVariable already registered but with a different name or provider, the key differs so the families cannot be merged; Astro warns 'Several font families have been registered for the X cssVariable but they do not share the same name and provider.' The practical effect (stated in the companion warning) is that the last occurrence silently overrides earlier families for that variable.","triggerScenarios":"Two entries in the `fonts` config array sharing an explicit cssVariable while differing in `name` or `provider` — e.g., copy-pasting a family block and changing only the name but keeping `cssVariable: '--font-sans'`.","commonSituations":"Duplicating a family entry to add weights then forgetting to change the variable; switching a family from one provider to another while keeping the variable; iterating on font configs during setup.","solutions":["Give each family its own unique cssVariable (or remove the explicit cssVariable so each family gets a unique default)","If you intended the families to merge, make name AND provider identical for every entry sharing the variable","Review the whole `fonts` array in astro.config after the fix — every duplicate pair warns only once at first sight"],"exampleFix":"// before: two families fight over --font-sans\nfonts: [\n  { provider: fontProviders.google(), name: 'Inter', cssVariable: '--font-sans' },\n  { provider: fontProviders.google(), name: 'Roboto', cssVariable: '--font-sans' },\n]\n\n// after: unique variables per family\nfonts: [\n  { provider: fontProviders.google(), name: 'Inter', cssVariable: '--font-inter' },\n  { provider: fontProviders.google(), name: 'Roboto', cssVariable: '--font-roboto' },\n]","handlingStrategy":"validation","validationCode":"// Fail fast in config when families reuse a cssVariable without matching name+provider\nconst variables = new Map<string, string>();\nfor (const f of fonts) {\n  const prev = variables.get(f.cssVariable);\n  const signature = `${f.name}|${f.provider}`;\n  if (prev && prev !== signature) {\n    throw new Error(`cssVariable ${f.cssVariable} reused by different families (${prev} vs ${signature})`);\n  }\n  variables.set(f.cssVariable, signature);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Omit cssVariable to let Astro derive unique defaults per family","Reserve one cssVariable per family; use separate variables for body/display faces","After copy-pasting a family block, change the cssVariable first, then the name"],"tags":["fonts","css-variable","configuration","experimental-assets"],"backgroundTag":"duplicate-css-variable-conflict","analyzedSha":"52e6c34790cc8ac4e69e6135ace06049867e5c4a","analyzedAt":"2026-08-18T18:48:03.901Z","contentChangedAt":"2026-08-18T18:48:03.901Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}