···11+---
22+title: Customize the "Overview" title of your Starlight Table of Contents
33+description: Learn how you can customize the first heading in the right sidebar of every Starlight page globally and individually.
44+date: 2025-11-22
55+tags:
66+ - Starlight
77+ - Education
88+authors:
99+ - trueberryless
1010+cover:
1111+ alt: A wooden desk featuring a small green plant positioned on its surface.
1212+ image: ../../../../public/blog/starlight-customize-toc-overview-title.jpg
1313+---
1414+1515+import { Steps } from '@astrojs/starlight/components';
1616+1717+This guide shows how you can customize the first heading in the right sidebar (table of contents) of every [Starlight](https://starlight.astro.build) page globally and individually.
1818+1919+{/* excerpt */}
2020+2121+Each Starlight page contains a table of contents on the right side (except if [disabled](https://starlight.astro.build/reference/frontmatter/#tableofcontents)). To be able to link to the top of the page, the first entry of this sidebar has the title "Overview" (as you can also see on this page's sidebar), which can be customized [globally](#global-definition) and even on a [per-page basis](#frontmatter-override).
2222+2323+## Global definition
2424+2525+If you want to set the title of the first table of contents entry once for all pages, you can follow these steps to achieve this for monolingual and multilingual sites:
2626+2727+<Steps>
2828+2929+1. Create [route middleware](https://starlight.astro.build/guides/route-data/#how-to-customize-route-data) to customize the data shown by Starlight.
3030+3131+2. Use this example code to configure the "Overview" title:
3232+3333+ ```ts ""Back to top""
3434+ // src/routeData.ts
3535+ import { defineRouteMiddleware } from "@astrojs/starlight/route-data";
3636+3737+ export const onRequest = defineRouteMiddleware((context) => {
3838+ const { starlightRoute } = context.locals;
3939+4040+ const overviewItem = starlightRoute.toc?.items[0];
4141+ if (overviewItem) overviewItem.text = "Back to top";
4242+ });
4343+ ```
4444+4545+3. If your site is [multilingual](https://starlight.astro.build/guides/i18n/), you can also assign different titles depending on the locale:
4646+4747+ ```ts ins="translations[locale ?? defaultLang]" ins={3-13,17}
4848+ // src/routeData.ts
4949+ import { defineRouteMiddleware } from "@astrojs/starlight/route-data";
5050+ import starlightConfig from "virtual:starlight/user-config";
5151+5252+ const defaultLang =
5353+ starlightConfig.defaultLocale.lang ??
5454+ starlightConfig.defaultLocale.locale ??
5555+ "en";
5656+5757+ const translations: Record<string, string> = {
5858+ en: "Back to top",
5959+ de: "Zurück nach oben",
6060+ };
6161+6262+ export const onRequest = defineRouteMiddleware((context) => {
6363+ const { starlightRoute } = context.locals;
6464+ const { locale } = starlightRoute;
6565+6666+ const overviewItem = starlightRoute.toc?.items[0];
6767+ if (overviewItem) overviewItem.text = translations[locale ?? defaultLang];
6868+ });
6969+ ```
7070+7171+7272+</Steps>
7373+7474+## Frontmatter override
7575+7676+In order to set the first table of contents heading to something different on individual pages, follow the steps below:
7777+7878+<Steps>
7979+8080+1. [Extend your frontmatter schema](https://starlight.astro.build/reference/frontmatter/#customize-frontmatter-schema) in `src/content.config.ts`:
8181+8282+ ```ts del={8} ins={5,9-16}
8383+ // src/content.config.ts
8484+ import { defineCollection } from 'astro:content';
8585+ import { docsLoader } from '@astrojs/starlight/loaders';
8686+ import { docsSchema } from '@astrojs/starlight/schema';
8787+ import { z } from "astro/zod";
8888+8989+ export const collections = {
9090+ docs: defineCollection({ loader: docsLoader(), schema: docsSchema() }),
9191+ docs: defineCollection({
9292+ loader: docsLoader(),
9393+ schema: docsSchema({
9494+ extend: z.object({
9595+ overviewTitle: z.string().optional(),
9696+ }),
9797+ }),
9898+ }),
9999+ };
100100+ ```
101101+102102+2. This allows you to use the `overviewTitle` in your middleware like that:
103103+104104+ ```ts ins={6} ins=/(?<=\= )individualOverviewTitle/
105105+ // src/routeData.ts
106106+ import { defineRouteMiddleware } from "@astrojs/starlight/route-data";
107107+108108+ export const onRequest = defineRouteMiddleware((context) => {
109109+ const { starlightRoute } = context.locals;
110110+ const individualOverviewTitle = starlightRoute.entry.data.overviewTitle;
111111+112112+ const overviewItem = starlightRoute.toc?.items[0];
113113+ if (overviewItem)
114114+ overviewItem.text = individualOverviewTitle ?? "Back to top";
115115+ });
116116+ ```
117117+118118+</Steps>
119119+120120+For the sake of completeness, here is a multilingual middleware that supports overriding on individual pages:
121121+122122+```ts
123123+// src/routeData.ts
124124+import { defineRouteMiddleware } from "@astrojs/starlight/route-data";
125125+import starlightConfig from "virtual:starlight/user-config";
126126+127127+const defaultLang =
128128+ starlightConfig.defaultLocale.lang ??
129129+ starlightConfig.defaultLocale.locale ??
130130+ "en";
131131+132132+const translations: Record<string, string> = {
133133+ en: "Back to top",
134134+ de: "Zurück nach oben",
135135+};
136136+137137+export const onRequest = defineRouteMiddleware((context) => {
138138+ const { starlightRoute } = context.locals;
139139+ const { locale } = starlightRoute;
140140+ const individualOverviewTitle = starlightRoute.entry.data.overviewTitle;
141141+142142+ const overviewItem = starlightRoute.toc?.items[0];
143143+ if (overviewItem)
144144+ overviewItem.text =
145145+ individualOverviewTitle ?? translations[locale ?? defaultLang];
146146+});
147147+```
148148+149149+## Source code
150150+151151+You can also find the complete source code for all four variants on [GitHub](https://github.com/trueberryless/starlight-customize-toc-overview-title) or open the project directly in [StackBlitz](https://stackblitz.com/github/trueberryless/starlight-customize-toc-overview-title).
+9
src/content/docs/credits.mdx
···280280 usedOnUrl="/blog/tags/mindspace"
281281 />
282282 <ImageCredit
283283+ image="/public/blog/starlight-customize-toc-overview-title.jpg"
284284+ title="Brown Pine Cone on Table"
285285+ author="Mahbod Akhzami"
286286+ authorUrl="https://unsplash.com/@mahbodakhzami"
287287+ sourceUrl="https://unsplash.com/photos/brown-pine-cone-on-table-jc9dkaaEYr4"
288288+ usedOn='Customize the "Overview" title of your Starlight Table of Contents'
289289+ usedOnUrl="/blog/starlight-customize-toc-overview-title"
290290+ />
291291+ <ImageCredit
283292 image="/public/blog/terraform-variables-resolution.jpg"
284293 title="Brown Wooden Building under White Clouds During Daytime"
285294 author="@invadingkingdom"