Custom Head
Inject structured or raw HTML tags into every generated page head.
Docgo gives you two ways to add custom tags to the document <head>:
headindocgo.config.mjs- a raw HTML file configured by
headFile
For common SEO fields, prefer the seo config. Use custom head entries for
analytics, verification tags, extra font loading, or custom scripts.
Structured head entries
The head option accepts Docgo head entry tuples.
export default defineConfig({
head: [
['meta', { name: 'theme-color', content: '#2563eb' }],
['link', { rel: 'preconnect', href: 'https://fonts.googleapis.com' }],
['script', { src: 'https://example.com/analytics.js', async: true }],
],
});Tuple forms:
[tag, attributes][(tag, attributes, innerHTML)];Attribute values are escaped. true renders a bare attribute, while false,
null, and undefined omit the attribute.
['script', { async: true, defer: false }, 'console.log("loaded")'];Raw head file
headFile defaults to head.html.
export default defineConfig({
headFile: 'head.html',
});The file is read from the project root and injected into every page.
<meta name="generator" content="docgo" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />If the file does not exist, Docgo simply skips it.
Custom fonts
Docgo exposes CSS variables for the docs theme fonts.
<style>
:root {
--dg-font-sans: 'Inter', sans-serif;
--dg-font-mono: 'JetBrains Mono', monospace;
--font-sans: var(--dg-font-sans);
--font-mono: var(--dg-font-mono);
}
</style>--font-sans and --font-mono are included for bmates-ui components used by
the theme.
Ordering
Docgo renders built-in metadata first, then head, then headFile. If you
need to override a tag with a later declaration, put it in headFile.
