hit counter
Duncan McClean 0 minute read
March 22, 2018

RSS Feeds and Sitemaps in Statamic

Statamic is a flat-file content management system built on the Laravel framework.

If you've built a website with Statamic, you'll know that by default, Statamic does not automatically come with RSS feeds or Sitemaps. In this article I will show you how to setup a simple RSS feed and a simple sitemap for your Statamic website.

The first thing you will need is a Statamic site and a theme. Which you'll most likly have if you're reading this article.

First things first, create a new layout, I called mine xml.html, you can call it whatever you like. In that file, just copy and paste the following:

Now we can create two new templates. One for your sitemap and one for your RSS feed.

RSS Feed

This is the code I use for my RSS Feed on my site. You can fill it out with more details if you need to. It's just a really simple template.

Sitemap

Below is what I use for the sitemap on this site. Again, it's all really basic. All the below sitemap does is get the latest from the blog collection and loops them.

After you have created the two files, you need to add them to your site/settings/routes.yaml file so they can actually be used.
Copy and paste the following into your routes file.

After you have copied it into your routes file, it should look something like this.

You should now be able to view your RSS feed and sitemap at the following URLs.

RSS Feed: https://your-site.com/feed

Sitemap: https://your-site.com/sitemap.xml


Comments