Meta tags and sitemap hints
Derive canonical, Open Graph and Twitter tags from the page's schemas, and pass crawl hints to a sitemap generator.
generateMeta
With generateMeta: true, the integration derives <meta> and <link> elements from the
primary schema of the page and inserts them into <head>. This runs as middleware after the
page has fully rendered, so it sees every schema on the page regardless of where the
components are placed, including components that await data first.
- Primary schema: the most page-specific schema wins (Article types, Product, Recipe,
VideoObject, Event, JobPosting, SoftwareApplication, ProfilePage, FAQPage, WebPage) before
site-wide LocalBusiness and WebSite schemas. It drives title, description, image and
og:type. An@typearray such as['BlogPosting', 'LearningResource']matches by each of its types. - Page schemas: page-level tags (
robots,hreflangalternates, the canonical URL) come from the schemas describing the page itself,WebPageSchemaand its variants, whichever content schema is primary. With several of them, such as a FAQPage and a WebPage, settings from each count and robots directives from all of them are kept. AnoindexWebPage next to an Article staysnoindex. - Your tags win: tags the page already defines (same
nameorproperty, canonical,hreflang) are kept and not duplicated. If the page sets its ownog:image, the schema image’s width, height, type and alt are left out, and so istwitter:image(Twitter falls back toog:image). - Canonical and
og:urlare built fromsiteUrland the page path, or taken from aWebPageSchemaurlor an article’smainEntityOfPage. Theurlof an event, business or product is never used as the page’s canonical. If the page sets its own canonical link,og:urluses that URL too, so both always agree. - Rewrites: after a middleware rewrite (
next('/target')orcontext.rewrite()), the tags come from the schemas of the rewrite target, and the page path for the canonical is the target’s path, the same path the components build their page URLs from. To point an alias elsewhere, passurltoWebPageSchema. - A page with a primary schema but no
</head>fails the build.
HTML responses are buffered by the middleware rather than streamed.
Generated tags
- Canonical, description, robots, author,
reading-time(non-standard) - Alternates:
<link rel="alternate" hreflang="…">fromalternatesor fromworkTranslation(urlandinLanguageof each translation) - Open Graph:
og:title,og:description,og:imagewith width, height, type and alt,og:url,og:type,og:site_name,og:locale, and for articlesarticle:published_time,article:modified_time,article:author(author profile URLs; the name goes into<meta name="author">),article:section,article:tag; for videosog:video(plusog:video:secure_urlwith anembedUrl) andvideo:durationin seconds - Twitter:
twitter:card,twitter:title,twitter:description,twitter:image,twitter:image:alt,twitter:site,twitter:creator
Relative image URLs in the meta tags are resolved to absolute URLs with siteUrl the way a
browser would: /image.jpg against the origin, image.jpg against the site path. siteName,
locale, twitterSite and twitterCreator from the integration options fill the site-wide
tags.
Example
The ArticleSchema of the Quickstart on
/blog/hello-astro/, with structuredData({ generateMeta: true, siteName: 'Example Blog' })
and site: 'https://example.com', adds these tags to <head>:
<link rel="canonical" href="https://example.com/blog/hello-astro/">
<meta name="description" content="Our first post.">
<meta name="author" content="Ada Lovelace">
<meta property="og:title" content="Hello, Astro">
<meta property="og:description" content="Our first post.">
<meta property="og:url" content="https://example.com/blog/hello-astro/">
<meta property="og:image" content="https://example.com/img/hello.jpg">
<meta property="og:site_name" content="Example Blog">
<meta property="og:type" content="article">
<meta property="article:published_time" content="2026-10-01">
<meta property="article:modified_time" content="2026-10-01">
<meta name="twitter:title" content="Hello, Astro">
<meta name="twitter:description" content="Our first post.">
<meta name="twitter:image" content="https://example.com/img/hello.jpg">
<meta name="twitter:card" content="summary_large_image">
Robots and alternates
WebPageSchema accepts robots (e.g. 'noindex') and alternates
({ href, hreflang }[]). Both only drive meta tags and are not part of the JSON-LD. They
apply even when another schema on the page, such as an article, is the primary one:
<WebPageSchema title="Draft" robots="noindex" />
<ArticleSchema title="Draft post" … />
The page gets the article’s title and Open Graph tags plus <meta name="robots" content="noindex">.
Sitemap hints
Every component, and the generic <Schema>, accepts changefreq and priority:
<ArticleSchema … changefreq="weekly" priority={0.8} />
They are written as data attributes on the JSON-LD <script> tag (on the @graph script in
graph mode), not into the JSON-LD. A page has one sitemap entry, so all schemas on a page must
agree; conflicting values, a changefreq outside the sitemap protocol values or a priority
outside 0–1 fail the build. Post-build sitemap generators such as @casoon/astro-site-files
can read these attributes from the HTML. Without such a generator they have no effect.