Output parity with Next.js 16
The head is written in the order Next.js 16 writes it for the same input: the viewport block, then the title, the description, the application name, the authors (the…
The head is written in the order Next.js 16 writes it for the same input: the viewport block, then the title, the
description, the application name, the authors (the link before the meta), the manifest, the generator, the keywords,
the referrer, the creator, the publisher, the robots and googlebot, the rel lists, the alternates, the platform tags,
the verification, the Apple web app, Open Graph, Twitter, the app links and the icons last. These rules follow Next's
own source (resolve-opengraph.js, resolve-metadata.js, resolve-basics.js, metadata.js):
og:typeis written only whenopenGraph.typeis set.og:titleandog:descriptionfall back to the page's title and description only when anopenGraphobject exists.- A Twitter block inherits the page's title and description, and the Open Graph title, description and images, for what it
does not set. A page with Open Graph and no Twitter block gets one. The card is
summary_large_imagewith an image andsummarywithout. - Robots:
indexornoindex,followornofollow, then the other directives in Next's order (max-image-previewbeforemax-snippet), joined with,. A value isname:valuewith no space (unavailable_after:2030-01-01). - Keywords are joined with a bare comma (
a,b). - Icons and the manifest are written as given: a relative address stays relative.
metadataBaseapplies to the canonical, Open Graph and Twitter URLs. - A canonical, an alternate or
og:urlvalue of./is the page's own path, so a root layout'scanonical: "./"gives each page its address (/sign-ingetshttps://example.com/sign-in). The page's pathname comes from the request (or the client's location);resolveChaintakes it ascontext.pathname. - With
metadataBaseset, a root URL (/, no query) is written as the bare origin, without its slash (Next'sresolveAbsoluteUrlWithPathname): the home canonical ishttps://example.com. Without a base a relative value is written as the path.