Skip to content

Readable without JavaScript

Next.js htmlLimitedBots: why Twitterbot and GPTBot get different HTML

Find where your Next.js page puts its title for each user agent, decide whether AI crawlers belong on the htmlLimitedBots list, and extend it without losing the defaults.

By Cerys Eaton, SiteRender team · Published

This article was drafted with AI assistance from the sources listed below and edited and published by the SiteRender team.

Decide which bots get blocking metadata
  1. 1Check if metadata streamsOnly metadata that cannot be prerendered streams. Prerendered metadata is in the initial HTML for everyone.
  2. 2Compare user agentsFetch as a browser, Twitterbot/1.0 and GPTBot/1.0; note where the title tag sits relative to the end of the head.
  3. 3Extend, do not replaceSetting htmlLimitedBots overrides the default list, so copy the default pattern and append the bots you add.
  4. 4Weigh the costListed bots wait for generateMetadata, and with Cache Components they skip the prerendered shell.

A link preview on Slack finds your page title in the head. An AI crawler fetching the same page gets that title in the body instead. Both fetched one URL from one Next.js app, and both got a 200. They did not get the same HTML.

The cause is streaming metadata, and the switch that decides who gets which version is htmlLimitedBots. The reader side of this, a fetcher that disagrees with another fetcher, is covered in the server-side rendering check. This post is for the owner of the Next.js app: where your metadata lands for each user agent, and whether to change the list.

Two versions of one page

Since Next.js 15.2.0, generateMetadata can stream. The server sends the first UI without waiting for metadata. When generateMetadata resolves, the tags are appended to the <body>. Next.js says it has verified that bots which execute JavaScript and inspect the full DOM, such as Googlebot, read that correctly.

For HTML-limited bots, which cannot execute JavaScript, Next.js waits for generateMetadata before it starts the response, and the tags go into the <head>. Next.js picks the branch by the User-Agent header.

One condition first: a page whose metadata can be prerendered, with nothing dynamic in generateMetadata, has its metadata in the initial HTML for everyone. The split only shows on routes where metadata resolves at request time.

Who is on the default list

The default pattern lives in html-bots.ts in the Next.js source. On the canary branch it currently reads:

/[\w-]-Google|Google-[\w-]|Chrome-Lighthouse|Slurp|DuckDuckBot|baiduspider|yandex|sogou|bitlybot|tumblr|vkShare|quora link preview|redditbot|ia_archiver|Bingbot|BingPreview|applebot|facebookexternalhit|facebookcatalog|Twitterbot|LinkedInBot|Slackbot|Discordbot|WhatsApp|SkypeUriPreview|Yeti|googleweblight/i

Link-preview bots and search crawlers. No GPTBot, ClaudeBot or PerplexityBot. A comment in the file gives the reason for the list: these bots may look for metadata in the head tag, so the response cannot stream metadata after the head was sent.

So on a route with request-time metadata, an AI crawler gets the browser version: title and description appended to the body.

Check where your title lands

Fetch the page as three clients and compare the byte offset of <title with the offset of </head>:

URL=https://example.com/
for UA in 'Mozilla/5.0' 'Twitterbot/1.0' 'GPTBot/1.0'; do
  curl -sL -A "$UA" -H 'Accept-Encoding: identity' "$URL" -o page.html
  head_end=$(grep -bo '</head>' page.html | head -1 | cut -d: -f1)
  title_at=$(grep -bo '<title' page.html | head -1 | cut -d: -f1)
  printf '%-16s </head> at %s   <title at %s\n' "$UA" "${head_end:-none}" "${title_at:-none}"
done

GPTBot/1.0 here is a test string, not the crawler's full user agent. It is enough for this check, because Next.js tests the header against a regular expression without anchors, so a substring match counts.

Read the result:

  • <title before </head> for all three: the metadata is not streaming on this route. Nothing to change.
  • Before </head> for Twitterbot, after it for the browser and GPTBot: streaming metadata is on, and the AI crawler gets the body version.
  • none for the title: check that the route sets a title at all.

Run the same loop with og:title in place of <title if link previews are what you care about.

Add AI crawlers without losing the defaults

The docs are explicit: a custom htmlLimitedBots value overrides the default list. Set it to /GPTBot/ and Twitterbot, Slackbot and the Google crawlers fall back to streamed metadata. Append to the default instead:

// next.config.js
// Default copied from html-bots.ts in the Next.js source; re-copy it when you upgrade.
const NEXT_DEFAULT_HTML_LIMITED_BOTS =
  /[\w-]-Google|Google-[\w-]|Chrome-Lighthouse|Slurp|DuckDuckBot|baiduspider|yandex|sogou|bitlybot|tumblr|vkShare|quora link preview|redditbot|ia_archiver|Bingbot|BingPreview|applebot|facebookexternalhit|facebookcatalog|Twitterbot|LinkedInBot|Slackbot|Discordbot|WhatsApp|SkypeUriPreview|Yeti|googleweblight/i

module.exports = {
  htmlLimitedBots: new RegExp(
    NEXT_DEFAULT_HTML_LIMITED_BOTS.source + '|GPTBot|ClaudeBot|PerplexityBot',
    'i'
  ),
}

Keep the i flag; the default pattern is case-insensitive. Run the curl loop again after the deploy. The GPTBot line should now look like the Twitterbot line.

The blunt version is htmlLimitedBots: /.*/, which the docs give as the way to turn streaming metadata off for every client.

What a listed bot pays for it

Blocking metadata is not free, and the cost lands on the requests that match the list.

  • Wait time. The response starts only after generateMetadata resolves. The docs warn that overriding the list could lead to longer response times. In the streaming guide's own demo, a Twitterbot/1.0 request waits for the full render, around 3 seconds on that page, and then gets the whole document in one burst.
  • A different render path. With Cache Components, browsers and DOM-capable crawlers get the prerendered shell at once. HTML-limited bots skip that shell and render the page dynamically. If the shell depends on data that exists only at build time, the page can work for a person and fail for a listed bot. Every bot you add inherits that risk.

Add only the user agents whose output you care about, and test the routes that use Cache Components with the bot user agent before you ship.

Metadata is not content

htmlLimitedBots changes when the response starts and where the metadata tags go. It does not move a client-rendered section to the server: text that a component fetches in the browser is missing from the HTML for every fetcher that does not run JavaScript, listed or not. Whether a given AI crawler runs JavaScript at all is a separate question, covered in the AI crawler guide. The safe default for a site owner stays the same: title, description and main text in the HTML the server sends.

Test it yourself

Pick the route with the slowest generateMetadata in your app. Run the curl loop as a browser, as Twitterbot/1.0 and as GPTBot/1.0. If the title sits after </head> for GPTBot, decide whether that matters for you, extend the default list rather than replacing it, and run the loop again.

Frequently asked questions

What does htmlLimitedBots do in Next.js?

It sets the user agents that get blocking metadata. For those bots, Next.js waits for generateMetadata before it starts the response, so the metadata is in the head of the initial HTML. Other clients can get streaming metadata, which is appended to the body once it resolves. The option was introduced in Next.js 15.2.0.

Is GPTBot on the default htmlLimitedBots list?

No. The default pattern in the Next.js source includes Twitterbot, Slackbot, Bingbot, facebookexternalhit and Google crawlers such as AdsBot-Google, but it does not mention GPTBot, ClaudeBot or PerplexityBot. Those user agents get the same streamed response as a browser.

How do I add GPTBot to htmlLimitedBots without breaking Twitterbot?

A custom htmlLimitedBots value replaces the default list. Copy the default regular expression from the Next.js source, append GPTBot and any other user agents, and keep the case-insensitive flag. Re-check the default pattern when you upgrade Next.js.

Does streaming metadata affect every Next.js page?

No. If a page can be prerendered and generateMetadata does not introduce dynamic behavior, the metadata is part of the initial HTML for every client. Streaming metadata applies when metadata resolves at request time.

What happens if I set htmlLimitedBots to match everything?

The pattern /.*/ turns streaming metadata off for all clients. The Next.js docs warn that overriding the list could lead to longer response times.

Sources

  1. htmlLimitedBots (Next.js docs) (Documentation)
  2. html-bots.ts default list (Next.js source) (Documentation)
  3. generateMetadata: Streaming metadata (Next.js docs) (Documentation)
  4. Streaming: Bots and crawlers (Next.js docs) (Documentation)
  5. loading.js: SEO (Next.js docs) (Documentation)