From 2890996e78752c8c6b0862baa081bdeeb324e7a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samy=20Pess=C3=A9?= Date: Mon, 1 Sep 2025 13:02:03 +0200 Subject: [PATCH] Fix order in robots.txt preventing indexation of images by Google --- .changeset/pink-turtles-switch.md | 5 +++++ packages/gitbook/src/routes/robots.ts | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/pink-turtles-switch.md diff --git a/.changeset/pink-turtles-switch.md b/.changeset/pink-turtles-switch.md new file mode 100644 index 0000000000..50c7a53ec0 --- /dev/null +++ b/.changeset/pink-turtles-switch.md @@ -0,0 +1,5 @@ +--- +"gitbook": patch +--- + +Fix order in robots.txt preventing indexation of images by Google. diff --git a/packages/gitbook/src/routes/robots.ts b/packages/gitbook/src/routes/robots.ts index 05fd7fb021..480042b5d2 100644 --- a/packages/gitbook/src/routes/robots.ts +++ b/packages/gitbook/src/routes/robots.ts @@ -13,11 +13,11 @@ export async function serveRobotsTxt(context: GitBookSiteContext) { const lines = isIndexable ? [ 'User-agent: *', + // Disallow other dynamic routes / search queries + 'Disallow: /*?', // Allow image resizing and icon generation routes for favicons and search results 'Allow: /~gitbook/image?*', 'Allow: /~gitbook/icon?*', - // Disallow other dynamic routes / search queries - 'Disallow: /*?', 'Allow: /', `Sitemap: ${linker.toAbsoluteURL(linker.toPathInSpace(isRoot ? '/sitemap.xml' : '/sitemap-pages.xml'))}`, ]