Skip to content

Title

Title renders the <title> tag for the document. It accepts a required page-specific value and an optional template containing a %s placeholder, which is replaced with value at render time.

proptypedefaultrequireddescription
valuestring-YesThe page-specific title text substituted into the template at the %s placeholder position.
template`${string}%s${string}`"%s"NoTemplate string containing a %s placeholder that is replaced by value. Falls back to headTags.titleTemplate from integration config, then "%s" if neither is set.

Input:

<Title value="Home" />

Output:

<title>Home</title>

Uses the integration headTags.titleTemplate value when template is not provided.

Input:

// in astro.config.mjs integration config
eminence({
headTags: {
titleTemplate: "%s | My Site",
},
});
<Title value="Home" />

Output:

<title>Home | My Site</title>

Input:

<Title value="Home" template="%s | My Site" />

Output:

<title>Home | My Site</title>

Template uses %s as the single placeholder

Section titled “Template uses %s as the single placeholder”

The placeholder convention is %s, a widely recognized pattern for string interpolation. The type is constrained to `${string}%s${string}` so TypeScript enforces that the template always contains the placeholder.

Integration config can define a site-wide template

Section titled “Integration config can define a site-wide template”

When template is omitted, the component falls back to headTags.titleTemplate from the integration config. If neither is set, the default is "%s", which renders the value as-is. This allows a site-wide suffix or prefix to be configured once and applied consistently across all pages without per-page repetition.

Unlike most other head components, value is not optional. A title tag without content would produce an empty or incorrect document title, so the component requires it unconditionally.

---
import config from "virtual:eminence-astro-suite/head-tags";
interface Props {
/**
* The page-specific title text.
*/
value: string;
/**
* Optional template string containing `%s` as a placeholder for the value.
* @default "%s" via integration virtual config
* @example "%s | My Site"
*/
template?: `${string}%s${string}`;
}
const { value, template = config.titleTemplate } = Astro.props;
---
<title>{template.replace("%s", value)}</title>