Brian's Website

Added an RSS Feed

  1. Followed the guide at the Eleventy RSS page, starting with installing the Eleventy's RSS plugin with npm install @11ty/eleventy-plugin-rss.
  2. In .eleventy.js added a constant and a plugin to make a virtual template with this code:
<!--- This is the new constant -->
const { feedPlugin } = require("@11ty/eleventy-plugin-rss");

<!--- This goes with the filters previously added -->
eleventyConfig.addPlugin(feedPlugin, {
	type: "atom", // or "rss", "json"
	outputPath: "/feed.xml",
	collection: {
		name: "posts", // iterate over `collections.posts`
		limit: 0,     // 0 means no limit
	},
	metadata: {
		language: "en",
		title: "Brian's Website",
		subtitle: "These are posts from Brian's Website.",
		base: "https://brianjasonford.com",
		author: {
			name: "Brian Ford",
			email: "", // Optional
		}
	}
});
  1. Ran npm start to start Eleventy, which makes feed.xml in /public.
  2. Added a link to the feed on the homepage in homepage.njk. I did not do this in index.md because I wanted it at the bottom and editing the layout made that easier. This is the code:
<h2>📡 Feed</h2>
Subscribe: <a href="./feed.xml">RSS/Atom feed</a> for your reader of choice.
  1. Edited the posts.njk layout to also include a link to the feed at the bottom of every post.