My portfolio website is built with Nuxt 3 and Nuxt Content v2. An RSS feed with my latest five blog posts is available here. In this article, you'll learn how to add an RSS feed to your Nuxt website.
Setup
First, let's create a new Nuxt 3 project. As the next step, we need to add the Nuxt Content v2 module to our application.
Finally, let's add some content that will be included in the RSS feed:
Each .md
file has this simple structure:
The source code for this demo is available at GitHub and in this StackBlitz playground:
Add Server Route
We will be utilizing the server routes available within Nuxt, and to do so, we'll need to create the server/
directory within our app root directly.
Once this is done, we create a routes/
directory inside this and add a rss.xml.ts
file. It will translate to /rss.xml
:
The next step is to query our blog posts:
Now let's add the rss library to generate the RSS XML string based on our content:
When using nuxt generate
, you may want to pre-render the feed since the server route won't be able to run on a static hosting.
We can do this by using the nitro.prerender
option in nuxt.config
:
If we now navigate to /rss.xml
, we get our generated RSS feed:
If you liked this article, follow me on Twitter to get notified about new blog posts and more content from me.
Alternatively (or additionally), you can also subscribe to my newsletter.
How to Create a Custom Code Block With Nuxt Content v2
Code blocks are essential for blogs about software development. In this article, I want to show you how can define a custom code block component in Nuxt Content v2 with the following features:
Building a Polite Newsletter Popup With Nuxt 3
This year I launched a free eBook with 27 helpful tips for Vue developers for subscribers of my weekly Vue newsletter. For marketing purposes, I showed a popup on the landing page of my portfolio page each time a user visited my site. I was aware that users probably could get annoyed by that popup. Thus I added a "Don't show again" button to that popup. I thought I solved the problem!