Four Silent Sitemap & SEO Bugs I Found Auditing My Next.js 16 Blog
A quick primer on sitemaps, robots.txt, and canonical URLs—followed by four real indexing bugs I caught and fixed on reggiepangilinan.com.

You can write the most helpful technical article in the world, and it still won't show up on Google if search engines can't cleanly discover, crawl, and understand your pages. 🔍
Before getting into the bugs I found on reggiepangilinan.com, here is a quick, plain-English refresher on the four technical SEO building blocks every site relies on.
🧭 Quick Primer: Why Technical SEO Matters
Search engines like Google send automated crawlers across the web to find pages, figure out what they're about, and decide whether to include them in search results. Technical SEO is simply making that crawler's job unambiguous:
Why SEO matters: Organic search is the easiest way for people looking for a specific solution to stumble onto your writing months or years after you publish—without you constantly sharing links on social media.
What
robots.txtdoes: It's the "house rules" file at/robots.txtthat tells crawlers which paths they can visit, which internal paths to ignore (like/api), and where to find your sitemap.What
sitemap.xmlis for: Think of it as the table of contents for search engines. Instead of hoping a crawler clicks every link on your site to find a new post,/sitemap.xmlhands Google a clean list of every public URL plus a<lastmod>date showing when each page was last updated.What Canonical URLs do: The same page can sometimes be reached in multiple ways (with query parameters, trailing slashes, or across paginated routes). A
<link rel="canonical">tag tells Google which exact URL is the "official" version so your search ranking doesn't get split across duplicates.
Sitemaps are easy to set up once, see returning 200 OK XML, and assume will just work forever. When I audited robots.txt, sitemap.xml, sitemap-isr.xml, and my paginated blog routes, I caught four silent bugs that were quietly undermining indexing.

🧊 1. /sitemap.xml Was Statically Frozen at Build Time
This was the biggest surprise—and you could actually see it hiding in plain sight in the next build route table!
In Next.js App Router, a GET Route Handler with no export const revalidate and no export const dynamic is statically prerendered once at build time and never revalidated on its own.
My src/app/sitemap-isr.xml/route.ts had export const revalidate = 21600, but src/app/robots.txt/route.ts pointed Google to /sitemap.xml—and src/app/sitemap.xml/route.ts had no revalidate export at all!
That meant every time I published a new post in Contentful, it wouldn't show up in /sitemap.xml until the next full Netlify deploy.
The Fix
Adding export const dynamic = 'force-dynamic' to src/app/sitemap.xml/route.ts with Cache-Control: public, max-age=0, s-maxage=60, stale-while-revalidate=300 turned it into a live dynamic route (ƒ /sitemap.xml in next build). Removing the old 6-hour max-age=21600, s-maxage=21600 header also prevents browsers and Netlify's CDN from serving stale XML for hours—so newly published posts appear in /sitemap.xml within 60 seconds!
💣 2. The Hidden 10-Post Cap
Both src/app/sitemap.xml/route.ts and src/app/sitemap-isr.xml/route.ts were fetching posts like this:
const { items: blogPosts } = await getBlogPosts()
Easy to overlook—except getBlogPosts(limit = 10, skip = 0) in src/lib/contentful.ts defaults to limit = 10!
Everything looked fine while I had fewer than 10 posts. The exact day I published post #11, my oldest articles would have quietly vanished from both sitemaps. 😅
The Fix
Passing getBlogPosts(1000, 0) (Contentful's max single-page limit) in both sitemap routes ensures every published article stays listed as the blog grows.
🕒 3. Stale <lastmod> Timestamps & XML Escaping
Previously, every blog post's <lastmod> tag only read fields.publishDate. If I went back a week later to fix broken links, add a diagram, or update a section, the <lastmod> date in /sitemap.xml never moved—so search crawlers had no signal to re-crawl the updated article.
The Fix
I added a small getPostLastMod() helper in src/app/sitemap.xml/route.ts and src/app/sitemap-isr.xml/route.ts that:
Compares
fields.publishDateagainst Contentful'spost.sys.updatedAtand outputs the later date.Uses the newest
lastmodacross all posts for the/blogindex entry too.Runs every
<loc>URL throughescapeXml()(&,<,>,",') so the XML never breaks on unexpected characters.
🔗 4. Missing Canonical URLs on Paginated Pages
My homepage, /about, /blog, and /blog/[slug] all had clean canonical URLs via src/lib/seo.ts, but src/app/blog/page/[page]/page.tsx built its own generateMetadata() and omitted alternates.canonical.
The Fix
Added alternates: { canonical: joinUrl(SITE_CONFIG.url, '/blog/page/' + pageNumber) } right alongside its existing robots: pageNumber > 3 ? 'noindex, follow' : 'index, follow' rule so every paginated page declares its exact canonical URL cleanly.
✅ 5. Submit Once, Stay Synced Automatically
One common question with dynamic blogs is whether you need to manually resubmit your sitemap to Google Search Console every time you publish a new post.
No! Once https://reggiepangilinan.com/sitemap.xml is submitted once in Search Console:
robots.txtadvertises/sitemap.xmland blocks internal routes./sitemap.xmlrenders dynamically (force-dynamic) with a 60-second edge cache (s-maxage=60), and publishing in Contentful also triggersPOST /api/revalidateto clear cached blog pages immediately.Draft Preview pages automatically output
noindex, nofollowso unpublished drafts never leak into search results.
✨ Wrapping Up
Checking your next build route table and reading your sitemap generator line-by-line takes five minutes and can save months of invisible indexing issues. If you're running a Next.js App Router blog with a headless CMS, double-check that your /sitemap.xml route actually has a revalidate interval and isn't silently capped by a default pagination limit!
You can inspect all three updated files in sitemap.xml/route.ts, sitemap-isr.xml/route.ts, and blog/page/[page]/page.tsx on GitHub.
Related Posts
Adding AI-Powered Blog Search with Google Gemini in Next.js
How we added an intelligent, Gemini-powered search bar to a Next.js + Contentful blog—covering AI basics for non-specialists, why hybrid search beat Google Search Grounding and Vertex AI Search, real-world free-tier traffic estimates, and built-in cost guardrails.
Running a Full Next.js Blog on Free Tiers: A Contentful + Netlify Case Study
A data-backed case study breaking down Contentful Free, Netlify Free, and GitHub Free quotas (at the time of this writing), with real math on how many visitors, blog posts, and images a personal site can serve before ever paying a cent for infrastructure.
Generative Engine Optimization (GEO) in Next.js 16: llms.txt, RSS, JSON-LD & Crawler Access
A plain-English primer on Generative Engine Optimization (GEO) plus six concrete Next.js 16 upgrades: dynamic /llms.txt, /rss.xml, Person & WebSite JSON-LD, explicit AI bot rules, and non-JS visibility.