Skip to main content

Reusing content with variables

Content variables hold short shared strings, like product names, support addresses, company names. If you edit the wording once, each topic that uses these variables stays in sync.

In this template, you can find variables under docs/_variables/. There are two patterns:

PatternWhen to useMechanism
Fixed (no override)The value must be the same everywhereImport a named export from defaults.js
Default with overrideMost places use the site default, but one page needs a different valueUse the Var component, and optionally pass value

For larger reused blocks (notices, tips), see Reusing content with includes.

Fixed variables (no override)

Use this when a string must never differ by page, for example, a legal company name or the canonical product name.

  1. Open docs/_variables/defaults.js and add or edit a named export:

    docs/_variables/defaults.js
    export const productName = '3di Docusaurus Template';
    export const supportEmail = 'docs@example.com';
    export const companyName = '3di Information Solutions';
  2. In the topic (.mdx), import the names you need after the front matter:

    import {productName, supportEmail} from '@site/docs/_variables/defaults.js';
  3. Insert the value in the body with curly braces.
    In plain text or JSX attributes, {supportEmail} resolves to the string. Markdown link destinations do not — use an <a> tag for mailto: links:

    Contact <a href={`mailto:${supportEmail}`}>{supportEmail}</a> about {productName}.

Live example (fixed)

Contact docs@example.com about 3di Docusaurus Template (3di Information Solutions).

Variables with an optional override

Use this when the site has a default, but a specific topic may need a different string for that one insertion.

  1. Keep the defaults in docs/_variables/defaults.js as above.

  2. Import the Var component:

    import Var from '@site/docs/_variables/Var.js';
  3. Place <Var /> where the string should appear.
    The name prop must match an export in defaults.js:

    Configure <Var name="productName" /> before you publish.
  4. To override for this use only, add a value prop:

    Configure <Var name="productName" value="Billing API" /> before you publish.

    Omit value to keep the site default. The override applies only to that tag; other pages are unchanged.

Live examples (override)

  • Default: Configure 3di Docusaurus Template before you publish.
  • Overridden on this page only: Configure Billing API Docs before you publish.