DEV Community

gan liu
gan liu

Posted on

How I Fixed My Sitemap: [object Object] URLs Were Poisoning 5 Sites

The Bug

I have 8 niche tool sites built with AI. Yesterday I found 5 of them had [object Object] and undefined in their sitemap XML.

Root Cause

// BAD: concatenating object instead of property
const url = `https://site.com/${page}`;
// = https://site.com/[object Object]

// GOOD:
const url = `https://site.com/${page.slug}`;
Enter fullscreen mode Exit fullscreen mode

Check Yours

curl -s https://yoursite.com/sitemap.xml | grep -E "object Object|undefined|null"
Enter fullscreen mode Exit fullscreen mode

Fixed all 8 sites. Full rebuild + redeploy. Now tracking at livephotokit.com.

Top comments (0)