Configure SEO metadata

View as Markdown

When you want to customize how your pages appear in search results or social previews, you can set defaults at the site level or override them on individual pages.

Fern automatically generates all SEO metadata for every page in your documentation site. Search engines and social media previews work out of the box with no configuration required.

When you do want to customize SEO settings, you can set defaults at the site level or override them on individual pages. Keep titles between 50-60 characters and descriptions between 150-160 characters for optimal display.

The metadata configurations on this page are for SEO and social tags that aren’t visible to users. For visible footer links, see footer links configuration.

How it works

Fern looks for metadata values in this order:

  1. Page frontmatter — Custom SEO values for a specific page
  2. Site-level docs.yml — Default SEO values for all pages
  3. Automatic defaults — Generated from your page’s existing title, description, subtitle, or excerpt fields
Example

og:image is the image that appears in social media previews. If you don’t set og:image in a page’s frontmatter, Fern uses the site-wide og:image from docs.yml. If neither is configured, the tag is omitted entirely.

Site-wide defaults

Set default SEO metadata for your entire site in docs.yml. These apply to all pages unless overridden by page-specific metadata.

docs.yml
1metadata:
2 # Core metadata
3 og:site_name: "Square Developer Documentation"
4 og:title: "Square Developer Platform | Payments, Commerce & Banking APIs"
5 og:description: "Build with Square's suite of APIs and SDKs. Accept payments, manage inventory, create loyalty programs, and access financial services."
6 og:url: "https://developer.squareup.com/docs"
7 og:locale: "en_US"
8 canonical-host: "developer.squareup.com"
9
10 # Social image
11 og:image: "https://developer.squareup.com/images/docs-social-card.png"
12 og:image:width: 1200
13 og:image:height: 630
14 og:logo: "https://developer.squareup.com/images/square-logo.png"
15
16 # Twitter / X
17 twitter:title: "Square Developer Platform Documentation"
18 twitter:description: "Integrate payments, point-of-sale, inventory, and financial services into your applications with Square's developer platform."
19 twitter:handle: "@SquareDev"
20 twitter:image: "https://developer.squareup.com/images/twitter-card.png"
21 twitter:site: "@Square"
22 twitter:card: "summary_large_image"

Core metadata

Identity and descriptive fields used by search engines and shared across social platforms. Keep titles between 50–60 characters and descriptions between 150–160 characters for optimal display. Set canonical-host if your docs are accessible at multiple URLs (e.g., a custom domain and a buildwithfern.com subdomain) to tell search engines which URL is authoritative.

metadata.og:site_name
string

The name of your website for Open Graph tags.

metadata.og:title
string

The title shown in social media previews.

metadata.og:description
string

The description shown in social media previews.

metadata.og:url
string

The canonical URL of your documentation.

metadata.og:locale
string

The locale of your content (e.g., en_US).

metadata.canonical-host
string

The host of your documentation website. Used to set the canonical URL for metadata tags and documents like the sitemap. Defaults to the URL defined in instances.

Social image

The image displayed when your docs are shared on LinkedIn, Slack, Discord, and other platforms. Use a 1200x630px image for the best display across platforms — this is the standard Open Graph size and will render correctly in most previews. Avoid embedding text in the image since it may be cropped on some platforms.

metadata.og:image
string

The image shown in social media previews. Recommended size is 1200x630 pixels.

metadata.og:image:width
number

The width of your Open Graph image in pixels.

metadata.og:image:height
number

The height of your Open Graph image in pixels.

string

URL to your company logo.

Dynamic OG images Beta

Instead of using a single static image for all pages, you can enable dynamic OG image generation. When enabled, Fern automatically generates a unique og:image for each page that doesn’t have one set in frontmatter.

You can optionally provide a custom background image (og:background-image) for dynamically generated OG images.

docs.yml
1metadata:
2 og:dynamic: true
3 og:background-image: ./images/og-background.png # optional
metadata.og:dynamic
boolean

When true, enables dynamic OG image generation for pages that don’t have a custom og:image set.

metadata.og:background-image
string

A custom background image for dynamically generated OG images. Can be a URL or a relative file path. When set, this image is used as the background instead of a solid color.

Twitter / X

Controls how your docs appear in Twitter Card previews when shared on X.

metadata.twitter:title
string

The title shown in Twitter Card previews.

metadata.twitter:description
string

The description shown in Twitter Card previews.

metadata.twitter:handle
string

Your company’s Twitter handle.

metadata.twitter:image
string

The image shown in Twitter Card previews.

metadata.twitter:site
string

The Twitter handle for your website.

metadata.twitter:card
string

The Twitter Card type. Options are summary, summary_large_image, app, or player.

Page-level overrides

Configure SEO metadata in your page’s frontmatter to control how individual pages appear in search results and social shares. These settings override site-wide defaults.

Only the documented SEO fields are added to the HTML <head> as meta tags. Custom frontmatter fields won’t automatically appear in your page metadata. To add custom metadata, use custom JavaScript.

plantstore-quickstart.mdx
1---
2title: PlantStore API Quick Start
3headline: "Get Started with PlantStore API | Developer Documentation"
4keywords: plants, garden, nursery
5canonical-url: https://docs.plantstore.dev/welcome
6og:image: https://plantstore.dev/images/api-docs-banner.png
7og:image:width: 1200
8og:image:height: 630
9twitter:card: summary_large_image
10twitter:site: "@PlantStoreAPI"
11noindex: false
12nofollow: false
13---

Basic metadata

Page title, URL, and keyword fields used by search engines. Use headline when you need a different title for search engines than what appears as the visible page heading.

headline
string

When set, the <title /> tag in the document head will use this value rather than the title property. For example, your title might be “Quickstart” (shown in the sidebar and as the H1), while headline could be “Quickstart | PlantStore API Docs” to give search engines more context. If not set, Fern uses title with your site name appended.

canonical-url
string

Overrides the canonical URL for this page. Must be a full URL including the protocol (e.g., https://buildwithfern.com/learn/docs/content/frontmatter).

keywords
string

Comma-separated keywords relevant to the page (e.g., plants, garden, nursery). Accepts only comma-separated strings, not arrays.

Open Graph

Controls how this page appears when shared on LinkedIn, Slack, Discord, and other platforms that support Open Graph. Keep titles between 50–60 characters and descriptions between 150–160 characters for optimal display.

og:site_name
string

The name of your website as it should appear when your content is shared.

og:title
string

The title of your page as it should appear when your content is shared.

og:description
string

The description of your page as it should appear when your content is shared.

og:url
string

The URL of your page.

og:image
string

The URL of the image displayed when your content is shared.

og:image:width
number

The width of the image in pixels.

og:image:height
number

The height of the image in pixels.

og:locale
string

The locale of the page, typically in the format language_TERRITORY (e.g., en_US).

string

The URL of your logo image displayed when your content is shared.

Twitter / X

Controls how this page appears in Twitter Card previews when shared on X.

twitter:title
string

The title of your page as it should appear in a tweet.

twitter:description
string

The description of your page as it should appear in a tweet.

twitter:handle
string

The Twitter handle of the page creator or site.

twitter:image
string

The URL of the image displayed in a tweet.

twitter:site
string

The Twitter handle for your website.

twitter:url
string

The URL of your page.

twitter:card
string

The type of card used for sharing on Twitter. Options: summary, summary_large_image, app, player.

Indexing

Control whether search engines index this page or follow its links. These are distinct: noindex removes the page from search results entirely, while nofollow keeps the page in results but tells search engines not to pass ranking credit through its links.

Use noindex for internal-only pages, staging content, or pages you don’t want surfaced in search. You can also combine noindex with hidden: true in docs.yml to hide a page from both search engines and the sidebar — see Hiding content for details. Use nofollow sparingly — it’s rarely needed for documentation.

noindex
boolean

If true, the page won’t be indexed by search engines and will be excluded from llms.txt endpoints.

nofollow
boolean

If true, search engines won’t follow any links on the page.