Sitemap generation
Why sitemaps matter
You can leverage your blog sitemap to maximize search engine crawling and indexation, and your RSS/ATOM feeds to syndicate your content out to your social media profiles and content networks. Search engines use your sitemap to thoroughly index your site. Google has stated that you should populate your sitemap with the canonical URL for every page you want indexed.Built-in blog sitemap
ButterCMS generates RSS, Atom, and sitemap XML markup for your blog. To use these on your blog, return the generated XML from the Butter API with the proper content type headers. Here’s what an example request looks like for getting your blog’s sitemap:RSS and Atom feeds
ButterCMS generates XML feeds for content syndication and SEO:- RSS Feed: Fully generated RSS 2.0 feed for your blog
- Atom Feed: Standards-compliant Atom 1.0 feed
- Sitemap: XML sitemap for search engine discovery
Fetching feeds
Building sitemaps for Pages
Unlike blog posts, your individual Pages in ButterCMS don’t have a preset schema. Additionally, although your Page content is stored in ButterCMS, the URL patterns associated with each page are decided by your app. For example, a single user-created Page Type, e.g., Case Study, might feed into multiple URL patterns:- A
/case-study/route that fetches all your Butter Case Study Pages - A
/case-study/slug/route that connects to a Case Study Detail view - A
/case-study/tag/tag-slug/route that fetches Case Studies with a specific tag
Step 1: fetch content from ButterCMS
There are a number of ways to fetch your content from ButterCMS, including SDKs for C#, Dart, Go, Java, JavaScript, PHP, Python, Ruby, and Swift. Or, you can fetch your content via a simple API call to the Pages API endpoint:page_size or limit parameters to determine how many results you want returned. You can also filter by any field using fields.key.
The response will look like:
Step 2: generate sitemap XML
The JSON response includes two pieces of information you’ll need for your sitemap: theslug of the page and the last updated datetime.
You can use this information and your dynamic URL pattern to write entries to your sitemap XML file:
Complete sitemap implementation
Node.js / Express example
Next.js example
Sitemap best practices
Before you launch ButterCMS, configure your sitemap properly:- If you are using ButterCMS to build an entire site, create a new sitemap and configure your app to update it whenever content is added or removed
- If you are using ButterCMS to implement a blog within an existing site, you can either create a new sitemap for your blog or work within the sitemap for the existing site
What to include
When indexing of new content is desired, add new URLs to the sitemap using the designated canonical URL when the new content is published:- Pages
- Posts
- Blog index page (blog home)
- Category index pages
- Tag index pages
- All other published content that should be indexed
What to exclude
When indexing of new content is not desired, add a noindex tag to the page head and do not add the content to the sitemap. Google recommends:- To prevent most search engine crawlers, add a noindex meta tag:
- To prevent only Google crawlers:
Syndicating to social media
To post your live blog posts to your Facebook account automatically, you can connect your blog RSS feed to your Facebook account.Submitting your sitemap
After generating your sitemap, submit it to search engines:
Also add your sitemap to
robots.txt: