Skip to content
Discussion options

You must be logged in to vote

Starting with Starlight 0.35.0, route data now include the head property which contains an array of all tags to include in the of the current page.

Such data can be customized using a route data middleware. For example, to add some meta tags for Open Graph images, this would look like the following:

// src/routeData.ts
import { defineRouteMiddleware } from "@astrojs/starlight/route-data";

export const onRequest = defineRouteMiddleware((context) => {
  // Get the URL of the Open Graph image to use.
  const ogImageUrl = new URL(`/og/my-og-image.png`, context.site);

  // Get the array of all tags to include in the `<head>` of the current page.
  const { head } = context.locals.starlightRoute;

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
3 replies
@SamuelLHuber
Comment options

@HiDeoo
Comment options

@SamuelLHuber
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by delucis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants