Skip to content

re: Dynamic Sitemaps with Contentful and Next.js a.k.a 'look ma no webhooks' VIEW POST


Great post Mike! Curious how you feel about the circular dependency issues in xmlbuilder? I need to implement a similar solution in a mono repo using rollup and running into circular issues.


Hi Aimee,

So I haven't run into circular issues with xmlbuilder with this implementation. However, I have run into this many times with Contentful. The most common foot gun when working in Contentful is having a Content type that also contains a reference to itself. This is typically something that happens if you want to say have a blog post with a list of recommended blog posts that also contain their own blog post recommendations. What I think you have to do for the site map is set the include level to one so it doesn't fetch deeply nested references. In general I try to avoid doing that type of referencing with Contentful now and rather use an additional query for a use case like recommended articles and recommended products etc.

I hope that helps a bit but I know circular references can be very frustrating.


Thanks for the reply Mike!

I found that the xmlbuilder library has some circular dependency issues, but they have been fixed in xmlbuilder2! We've handled our Contentful related issues with some safe stringifiying, and definitely learned that includes query param lesson the hard way :)


code of conduct - report abuse