Re: [PR] fix(seo): reduce sitemap bloat by filtering versioned docs and low-value pages [apisix-website]

2026-04-12 Thread via GitHub


Yilialinn merged PR #2016:
URL: https://github.com/apache/apisix-website/pull/2016


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] fix(seo): reduce sitemap bloat by filtering versioned docs and low-value pages [apisix-website]

2026-04-09 Thread via GitHub


Copilot commented on code in PR #2016:
URL: https://github.com/apache/apisix-website/pull/2016#discussion_r3059394849


##
scripts/update-sitemap-loc.js:
##
@@ -15,6 +15,53 @@ const sitemapXMLs = [
   ],
 ];
 
+/**
+ * URL patterns to exclude from the sitemap.
+ *
+ * Why:
+ * - Versioned doc URLs (e.g. /docs/apisix/3.14/) duplicate the latest
+ *   unversioned paths (e.g. /docs/apisix/) and bloat the sitemap.
+ *   Only the unversioned (latest) URLs should be indexed.
+ * - /docs/.../next/ pages are for unreleased development docs.
+ * - /search pages are blocked by robots.txt — keeping them in
+ *   the sitemap sends contradictory signals to crawlers.
+ * - /blog/tags/ and /blog/page/ are low-value aggregation/pagination
+ *   pages, also blocked by robots.txt.
+ */
+const excludePatterns = [
+  // Versioned docs: /docs/// where version is digits.digits
+  /\/docs\/[\w-]+\/\d+\.\d+\//,
+  // Development "next" docs
+  /\/docs\/[\w-]+\/next\//,
+  // Search pages (blocked by robots.txt)
+  /\/search\/?$/,
+  // Blog tag and pagination pages (blocked by robots.txt)
+  /\/blog\/tags\//,
+  /\/blog\/page\//,
+];

Review Comment:
   The versioned-docs and `next` patterns only match when there’s a trailing 
`/` after the version/`next` segment. If the sitemap ever contains URLs like 
`/docs/apisix/3.14` or `/docs/apisix/next` (no trailing slash), they will not 
be filtered. Update the patterns to also match end-of-string after the segment 
(e.g., `(?:/|$)`), so both forms are excluded.



##
scripts/update-sitemap-loc.js:
##
@@ -15,6 +15,53 @@ const sitemapXMLs = [
   ],
 ];
 
+/**
+ * URL patterns to exclude from the sitemap.
+ *
+ * Why:
+ * - Versioned doc URLs (e.g. /docs/apisix/3.14/) duplicate the latest
+ *   unversioned paths (e.g. /docs/apisix/) and bloat the sitemap.
+ *   Only the unversioned (latest) URLs should be indexed.
+ * - /docs/.../next/ pages are for unreleased development docs.
+ * - /search pages are blocked by robots.txt — keeping them in
+ *   the sitemap sends contradictory signals to crawlers.
+ * - /blog/tags/ and /blog/page/ are low-value aggregation/pagination
+ *   pages, also blocked by robots.txt.
+ */
+const excludePatterns = [
+  // Versioned docs: /docs/// where version is digits.digits
+  /\/docs\/[\w-]+\/\d+\.\d+\//,
+  // Development "next" docs
+  /\/docs\/[\w-]+\/next\//,
+  // Search pages (blocked by robots.txt)
+  /\/search\/?$/,
+  // Blog tag and pagination pages (blocked by robots.txt)
+  /\/blog\/tags\//,
+  /\/blog\/page\//,
+];
+
+/**
+ * Returns true if the URL should be excluded from the sitemap.
+ */
+function shouldExclude(url) {
+  return excludePatterns.some((pattern) => pattern.test(url));
+}
+
+/**
+ * Filter out excluded URLs from a sitemap object and return removal count.
+ */
+function filterSitemapUrls(sitemap) {
+  const urls = Array.isArray(sitemap.urlset.url)
+? sitemap.urlset.url
+: [sitemap.urlset.url];
+  const before = urls.length;
+  sitemap.urlset.url = urls.filter((entry) => {
+const loc = entry.loc && entry.loc._text;
+return !loc || !shouldExclude(loc);

Review Comment:
   This currently *keeps* entries that don’t have a valid `loc` (`return !loc 
|| ...`). In a sitemap, entries without `loc` are invalid and should be removed 
to avoid generating a malformed sitemap. Consider changing the predicate to 
require `loc` and then apply the exclude filter (i.e., drop entries without 
`loc`).
   ```suggestion
   return Boolean(loc) && !shouldExclude(loc);
   ```



##
scripts/update-sitemap-loc.js:
##
@@ -42,6 +89,8 @@ const tasks = new Listr([
 ...sitemaps[i].urlset.url,
   ];
 }
+const removed = filterSitemapUrls(res);
+console.log(`  Filtered out ${removed} URLs from ${group[0]}`);

Review Comment:
   Using `console.log` inside a Listr task can produce messy/duplicated output 
(especially in CI) and may interfere with Listr’s rendering. Prefer reporting 
via Listr’s mechanisms (e.g., task output) so logs are consistently formatted 
and don’t break progress rendering.



##
website/static/robots.txt:
##
@@ -2,6 +2,119 @@
 
 User-agent: *
 
+# Blog aggregation and pagination pages (low-value for indexing)
+Disallow: /blog/tags/
+Disallow: /zh/blog/tags/
+Disallow: /blog/page/
+Disallow: /zh/blog/page/
+
+# Search pages
+Disallow: /search
+Disallow: /zh/search
+
+# Versioned docs — only the unversioned (latest) paths should be indexed.
+# e.g. /docs/apisix/ is the latest; /docs/apisix/3.14/ is a duplicate.
+Disallow: /docs/apisix/3.10/
+Disallow: /docs/apisix/3.11/
+Disallow: /docs/apisix/3.12/
+Disallow: /docs/apisix/3.13/
+Disallow: /docs/apisix/3.14/
+Disallow: /docs/apisix/3.15/
+Disallow: /docs/apisix/next/
+Disallow: /docs/ingress-controller/3.10/
+Disallow: /docs/ingress-controller/3.11/
+Disallow: /docs/ingress-controller/3.12/
+Disallow: /docs/ingress-controller/3.13/
+Disallow: /docs/ing

[PR] fix(seo): reduce sitemap bloat by filtering versioned docs and low-value pages [apisix-website]

2026-04-09 Thread via GitHub


moonming opened a new pull request, #2016:
URL: https://github.com/apache/apisix-website/pull/2016

   ## Summary
   
   Reduce the sitemap from ~5,200 URLs to ~2,700 by filtering out redundant 
versioned documentation pages, development docs, and low-value pages. Update 
robots.txt to match.
   
   ## Problem
   
   The sitemap includes every versioned doc page across 7 projects x 6 versions 
(3.10-3.15) + next. For example, `/docs/apisix/getting-started/` (latest) and 
`/docs/apisix/3.14/getting-started/` (old version) both appear. This wastes 
crawl budget and causes duplicate content confusion.
   
   Additionally, `/search`, `/blog/tags/`, and `/blog/page/` were being 
included in the sitemap despite being low-value pages.
   
   ## Changes
   
   ### 1. Sitemap merge script (`scripts/update-sitemap-loc.js`)
   
   Added URL filtering during post-build sitemap merge. Excludes:
   - `/docs///` - versioned doc pages
   - `/docs//next/` - unreleased dev docs
   - `/search`, `/blog/tags/`, `/blog/page/`
   
   Unversioned latest doc paths (e.g. `/docs/apisix/getting-started/`) are kept.
   
   ### 2. robots.txt (`website/static/robots.txt`)
   
   Added Disallow rules for all versioned doc paths, next docs, search, blog 
tags, and blog pagination across both locales. Ensures robots.txt and sitemap 
send consistent signals.
   
   ## Expected result
   
   - EN sitemap: ~2,638 -> ~1,360 URLs (~48% reduction)
   - ZH sitemap: ~2,620 -> ~1,340 URLs (~49% reduction)
   - Remaining URLs are high-value: latest docs, blog posts, main pages


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]