paritybit.ca

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit a641b4995bca96a4cfcd7851d0be35e6b2e7d59e
parent e5efdc722274ef00e79ce720d11386955ecd3c39
Author: Jake Bauer <jbauer@paritybit.ca>
Date:   Fri, 19 Jun 2020 23:59:39 -0400

Publish new blog post

Diffstat:
Mpages/blog.md | 1+
Apages/blog/how-to-create-an-rss-feed-for-your-blog-2.md | 149+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mpages/home.md | 4++--
Mpublic/feeds/sitewide-feed.xml | 55+++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mpublic/sitemap.xml | 1+
5 files changed, 208 insertions(+), 2 deletions(-)

diff --git a/pages/blog.md b/pages/blog.md @@ -20,6 +20,7 @@ href="https://social.paritybit.ca/@jbauer">Mastodon</a>. ### 2020 <ul> + <li>2020-06-19 <a href="blog/how-to-create-an-rss-feed-for-your-blog-2">How to Create an RSS Feed for Your Blog — 2 — The Basics</a></li> <li>2020-06-18 <a href="blog/how-to-create-an-rss-feed-for-your-blog-1">How to Create an RSS Feed for Your Blog – Part 1 — Why?</a></li> <li>2020-06-16 <a href="blog/my-beginnings-with-gentoo">My Beginnings with Gentoo</a></li> <li>2020-06-15 <a href="blog/my-new-t420s">My New T420s</a></li> diff --git a/pages/blog/how-to-create-an-rss-feed-for-your-blog-2.md b/pages/blog/how-to-create-an-rss-feed-for-your-blog-2.md @@ -0,0 +1,149 @@ +## How to Create an RSS Feed for Your Blog — 2 — The Basics + +[//]: # "If you have a blog then you should be syndicating your posts through an RSS feed. This is part 1 in a series about why you should have an RSS feed and how to do it." + +[//]: # "main.min.css" + +[//]: # "Beginning; The Basic Format of a Post; How to Link to Your Feed; Conclusion" + +<div class="byline"> +<b>Written By:</b> Jake Bauer | + <b>Posted:</b> 2020-06-19 | + <b>Last Updated:</b> 2020-06-19 +</div> + +This is the second part in a series about creating an RSS feed for your website. +[Click here to read the first +part](https://www.paritybit.ca/blog/how-to-create-an-rss-feed-for-your-blog-1) +about why you should have an RSS feed if you don't already have one. In this +part, I'll be describing the basics of creating an RSS feed for your site, what +should it include, how to let people know about it, and how you might want to +syndicate content through it. + +### Beginning + +RSS is written in XML. Therefore, it's a file composed of several tags with +special meaning. The basic structure of an RSS file looks as follows: + +```xml +<?xml version="1.0" encoding="utf-8"?> +<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> + <channel> + <atom:link href="https://example.com/feed.xml" + rel="self" type="application/rss+xml" /> + <title></title> + <link></link> + <description></description> + [ ... ITEMS GO HERE ... ] + </channel> +</rss> +``` + +The first line is a bit of boilerplate which identifies this file as using +version 1 of XML and defines the text encoding that the file uses. + +The next line is a bit of boilerplate which identifies the version of RSS we are +using and "imports" the Atom namespace which allows us to use Atom tags in our +RSS feed. + +The `<channel>` tag is a required bit of boilerplate and there can be only one +per RSS 2.0 file. It encapsulates items and the feed metadata. + +According to +[rssboard.org](https://rssboard.org/rss-profile#namespace-elements-aton), having +an `atom:link` element, as seen on the next line, is highly recommended because +it makes the feed more portable, self-contained, and easier to cache. The URL +specified by the `href` attribute should point to the location of your feed on +the Internet. + +Inside the `<channel>` tag, there must be at least a `<title>` tag containing +the title of your feed (e.g. "example.com's Blog"), a `<link>` tag containing a +link to the site that the feed is for (e.g. `https://www.example.com`), and a +`<description>` tag with a description of the feed (e.g. "The RSS feed for +example.com"). + +After the final required channel element, `<item>` tags can be used to define +individual entries in the RSS feed. + +### The Basic Format of a Post + +Posts are fairly simple to format. They are defined in `<item>` tags which +generally look like this: + +```xml +<item> + <title></title> + <link></link> + <pubDate></pubDate> + <description></description> +</item> +``` + +Most of the tags are straightforward. `<title>` refers to the title of the post +and is what will show up when someone is looking through a list of all items in +the feed, `<link>` is a link to the post on the Internet, `<pubDate>` contains +the date and time which the post was published and should look something like +`Thu, 18 Jun 2020 20:01:46 -0400`, and `<description>` contains either the full +content of the post, or just a description (if you choose to use Atom syntax, +there are separate `<summary>` and `<content>` tags). + +All of those tags are technically optional in the `<item>` tag. In fact, an +`<item>` tag is technically allowed to contain no elements at all so you're free +to pick and choose which bits of information you wish to include. A complete +list of tags and their uses is linked in the Conclusion section of this post. + +Regarding the `<description>` tag, much of the accessibility and ease-of-use +benefits of an RSS feed are realized when the `<description>` contains the full +text of the post. This allows someone to read your posts in their feed reader +which means they don't have to open a Web browser just to get the full version. +It is highly recommended (by me, and many other folks on the internet) to +include the full text of your posts in the `<description>` tag. + +In order to include HTML text in the `<description>` tag, you must either +convert HTML markup to HTML entities (e.g. `&lt;`, `&gt;`), or enclose the +content of the description in a CDATA section which will look like this: + +```xml +<description><![CDATA[<h2>My very interesting post</h2><p>This post contains <a +href="https://www.example.com">a link</a>.]]></description> +``` + +I personally use the CDATA method, as it allows me to easily copy and paste the +HTML of my posts into the `<description>` tags. + +### How to Link to Your Feed + +You may have seen the ubiquitous RSS Icon <img src="/img/feed-icon.png" +width="15" height="15" alt="An image of the RSS Icon"/> around the Web. Its use +is so pervasive that it's become like the floppy disk icon but for RSS feeds. +Make sure that you prominently feature either this icon (or something like it) +where people go to read your blogs, or provide a prominent link to where users +can find your feed. For example, I have the icon on both [my home page](/) and +[my blog page](/blog). + +Another standard that you should incorporate into your site is the use of a +`<link>` element in the `<head>` of your HTML files. It's a standard way to tell +the user's Web browser that an RSS feed is available for this site and where to +find it. The element should look something like this: + +```html +<link rel="alternate" type="application/rss+xml" title="RSS feed" + href="https://www.example.com/feed.xml"> +``` + +### Conclusion + +As you can see, RSS really isn't that complicated. You can get up and running +with a feed for your site in less than a half-hour. It's not even that hard to +write it by hand, though that will get tedious over time. In the next post, I'll +talk about how I automate updates to my RSS feed and show you that it's also +really simple to automate updating the feed. + +To learn more about available tags and what is and is not encouraged in RSS +feeds, see the [RSS Best Practices +Profile](https://www.rssboard.org/rss-profile). + +_This is my forty-ninth post for the +[#100DaysToOffload](https://social.paritybit.ca/tags/100DaysToOffload) +challenge. You can learn more about this challenge over at +[https://100daystooffload.com](https://100daystooffload.com)._ diff --git a/pages/home.md b/pages/home.md @@ -20,6 +20,8 @@ extent)! Access through `gopher://paritybit.ca` or `gemini://paritybit.ca`. src="/img/feed-icon.png" width="15" height="15" alt="Click for RSS Feed"/> </a> </div> +2020-06-19 <a class="feed-item" href="blog/how-to-create-an-rss-feed-for-your-blog-2">How to Create an RSS Feed for Your Blog — 2 — The Basics</a> + 2020-06-18 <a class="feed-item" href="blog/how-to-create-an-rss-feed-for-your-blog-1">How to Create an RSS Feed for Your Blog – Part 1 — Why?</a> 2020-06-16 <a class="feed-item" href="blog/my-beginnings-with-gentoo">My Beginnings with Gentoo</a> @@ -37,8 +39,6 @@ extent)! Access through `gopher://paritybit.ca` or `gemini://paritybit.ca`. 2020-06-11 <a class="feed-item" href="blog/trying-out-dwm">Trying Out dwm</a> 2020-06-09 <a class="feed-item" href="blog/setting-up-a-status-page">Setting Up a Status Page</a> - -2020-06-08 <a class="feed-item" href="blog/scripting-my-way-to-success">Scripting My Way to Success</a> ### What is a Parity Bit? It is a bit (in the 1's and 0's sense) used in checking for errors in digital diff --git a/public/feeds/sitewide-feed.xml b/public/feeds/sitewide-feed.xml @@ -7,6 +7,61 @@ <description>The feed that covers all notable additions, updates, announcements, and other changes for the entire paritybit.ca website.</description> <item> + <title>How to Create an RSS Feed for Your Blog — 2 — The Basics</title> + <link>https://www.paritybit.ca/blog/how-to-create-an-rss-feed-for-your-blog-2</link> + <guid>https://www.paritybit.ca/blog/how-to-create-an-rss-feed-for-your-blog-2</guid> + <pubDate>Fri, 19 Jun 2020 23:59:10 -0400</pubDate> + <description><![CDATA[<h2 id="how-to-create-an-rss-feed-for-your-blog-2-the-basics">How to Create an RSS Feed for Your Blog — 2 — The Basics</h2> +<div class="byline"> +<p><b>Written By:</b> Jake Bauer | <b>Posted:</b> 2020-06-19 | <b>Last Updated:</b> 2020-06-19</p> +</div> +<p>This is the second part in a series about creating an RSS feed for your website. <a href="https://www.paritybit.ca/blog/how-to-create-an-rss-feed-for-your-blog-1">Click here to read the first part</a> about why you should have an RSS feed if you don’t already have one. In this part, I’ll be describing the basics of creating an RSS feed for your site, what should it include, how to let people know about it, and how you might want to syndicate content through it.</p> +<h3 id="beginning">Beginning</h3> +<p>RSS is written in XML. Therefore, it’s a file composed of several tags with special meaning. The basic structure of an RSS file looks as follows:</p> +<div class="sourceCode" id="cb1"><pre class="sourceCode xml"><code class="sourceCode xml"><a class="sourceLine" id="cb1-1" title="1"><span class="kw">&lt;?xml</span> version=&quot;1.0&quot; encoding=&quot;utf-8&quot;<span class="kw">?&gt;</span></a> +<a class="sourceLine" id="cb1-2" title="2"><span class="kw">&lt;rss</span><span class="ot"> version=</span><span class="st">&quot;2.0&quot;</span><span class="ot"> xmlns:atom=</span><span class="st">&quot;http://www.w3.org/2005/Atom&quot;</span><span class="kw">&gt;</span></a> +<a class="sourceLine" id="cb1-3" title="3"> <span class="kw">&lt;channel&gt;</span></a> +<a class="sourceLine" id="cb1-4" title="4"> <span class="kw">&lt;atom:link</span><span class="ot"> href=</span><span class="st">&quot;https://example.com/feed.xml&quot;</span></a> +<a class="sourceLine" id="cb1-5" title="5"><span class="ot"> rel=</span><span class="st">&quot;self&quot;</span><span class="ot"> type=</span><span class="st">&quot;application/rss+xml&quot;</span> <span class="kw">/&gt;</span></a> +<a class="sourceLine" id="cb1-6" title="6"> <span class="kw">&lt;title&gt;&lt;/title&gt;</span></a> +<a class="sourceLine" id="cb1-7" title="7"> <span class="kw">&lt;link&gt;&lt;/link&gt;</span></a> +<a class="sourceLine" id="cb1-8" title="8"> <span class="kw">&lt;description&gt;&lt;/description&gt;</span></a> +<a class="sourceLine" id="cb1-9" title="9"> [ ... ITEMS GO HERE ... ]</a> +<a class="sourceLine" id="cb1-10" title="10"> <span class="kw">&lt;/channel&gt;</span></a> +<a class="sourceLine" id="cb1-11" title="11"><span class="kw">&lt;/rss&gt;</span></a></code></pre></div> +<p>The first line is a bit of boilerplate which identifies this file as using version 1 of XML and defines the text encoding that the file uses.</p> +<p>The next line is a bit of boilerplate which identifies the version of RSS we are using and “imports” the Atom namespace which allows us to use Atom tags in our RSS feed.</p> +<p>The <code>&lt;channel&gt;</code> tag is a required bit of boilerplate and there can be only one per RSS 2.0 file. It encapsulates items and the feed metadata.</p> +<p>According to <a href="https://rssboard.org/rss-profile#namespace-elements-aton">rssboard.org</a>, having an <code>atom:link</code> element, as seen on the next line, is highly recommended because it makes the feed more portable, self-contained, and easier to cache. The URL specified by the <code>href</code> attribute should point to the location of your feed on the Internet.</p> +<p>Inside the <code>&lt;channel&gt;</code> tag, there must be at least a <code>&lt;title&gt;</code> tag containing the title of your feed (e.g. “example.com’s Blog”), a <code>&lt;link&gt;</code> tag containing a link to the site that the feed is for (e.g. <code>https://www.example.com</code>), and a <code>&lt;description&gt;</code> tag with a description of the feed (e.g. “The RSS feed for example.com”).</p> +<p>After the final required channel element, <code>&lt;item&gt;</code> tags can be used to define individual entries in the RSS feed.</p> +<h3 id="the-basic-format-of-a-post">The Basic Format of a Post</h3> +<p>Posts are fairly simple to format. They are defined in <code>&lt;item&gt;</code> tags which generally look like this:</p> +<div class="sourceCode" id="cb2"><pre class="sourceCode xml"><code class="sourceCode xml"><a class="sourceLine" id="cb2-1" title="1"><span class="kw">&lt;item&gt;</span></a> +<a class="sourceLine" id="cb2-2" title="2"> <span class="kw">&lt;title&gt;&lt;/title&gt;</span></a> +<a class="sourceLine" id="cb2-3" title="3"> <span class="kw">&lt;link&gt;&lt;/link&gt;</span></a> +<a class="sourceLine" id="cb2-4" title="4"> <span class="kw">&lt;pubDate&gt;&lt;/pubDate&gt;</span></a> +<a class="sourceLine" id="cb2-5" title="5"> <span class="kw">&lt;description&gt;&lt;/description&gt;</span></a> +<a class="sourceLine" id="cb2-6" title="6"><span class="kw">&lt;/item&gt;</span></a></code></pre></div> +<p>Most of the tags are straightforward. <code>&lt;title&gt;</code> refers to the title of the post and is what will show up when someone is looking through a list of all items in the feed, <code>&lt;link&gt;</code> is a link to the post on the Internet, <code>&lt;pubDate&gt;</code> contains the date and time which the post was published and should look something like <code>Thu, 18 Jun 2020 20:01:46 -0400</code>, and <code>&lt;description&gt;</code> contains either the full content of the post, or just a description (if you choose to use Atom syntax, there are separate <code>&lt;summary&gt;</code> and <code>&lt;content&gt;</code> tags).</p> +<p>All of those tags are technically optional in the <code>&lt;item&gt;</code> tag. In fact, an <code>&lt;item&gt;</code> tag is technically allowed to contain no elements at all so you’re free to pick and choose which bits of information you wish to include. A complete list of tags and their uses is linked in the Conclusion section of this post.</p> +<p>Regarding the <code>&lt;description&gt;</code> tag, much of the accessibility and ease-of-use benefits of an RSS feed are realized when the <code>&lt;description&gt;</code> contains the full text of the post. This allows someone to read your posts in their feed reader which means they don’t have to open a Web browser just to get the full version. It is highly recommended (by me, and many other folks on the internet) to include the full text of your posts in the <code>&lt;description&gt;</code> tag.</p> +<p>In order to include HTML text in the <code>&lt;description&gt;</code> tag, you must either convert HTML markup to HTML entities (e.g. <code>&amp;lt;</code>, <code>&amp;gt;</code>), or enclose the content of the description in a CDATA section which will look like this:</p> +<div class="sourceCode" id="cb3"><pre class="sourceCode xml"><code class="sourceCode xml"><a class="sourceLine" id="cb3-1" title="1"><span class="kw">&lt;description&gt;</span><span class="bn">&lt;![CDATA[</span>&lt;h2&gt;My very interesting post&lt;/h2&gt;&lt;p&gt;This post contains &lt;a</a> +<a class="sourceLine" id="cb3-2" title="2">href=&quot;https://www.example.com&quot;&gt;a link&lt;/a&gt;.<span class="bn">]]&gt;</span><span class="kw">&lt;/description&gt;</span></a></code></pre></div> +<p>I personally use the CDATA method, as it allows me to easily copy and paste the HTML of my posts into the <code>&lt;description&gt;</code> tags.</p> +<h3 id="how-to-link-to-your-feed">How to Link to Your Feed</h3> +<p>You may have seen the ubiquitous RSS Icon <img src="/img/feed-icon.png" +width="15" height="15" alt="An image of the RSS Icon"/> around the Web. Its use is so pervasive that it’s become like the floppy disk icon but for RSS feeds. Make sure that you prominently feature either this icon (or something like it) where people go to read your blogs, or provide a prominent link to where users can find your feed. For example, I have the icon on both <a href="/">my home page</a> and <a href="/blog">my blog page</a>.</p> +<p>Another standard that you should incorporate into your site is the use of a <code>&lt;link&gt;</code> element in the <code>&lt;head&gt;</code> of your HTML files. It’s a standard way to tell the user’s Web browser that an RSS feed is available for this site and where to find it. The element should look something like this:</p> +<div class="sourceCode" id="cb4"><pre class="sourceCode html"><code class="sourceCode html"><a class="sourceLine" id="cb4-1" title="1"><span class="kw">&lt;link</span><span class="ot"> rel=</span><span class="st">&quot;alternate&quot;</span><span class="ot"> type=</span><span class="st">&quot;application/rss+xml&quot;</span><span class="ot"> title=</span><span class="st">&quot;RSS feed&quot;</span></a> +<a class="sourceLine" id="cb4-2" title="2"><span class="ot"> href=</span><span class="st">&quot;https://www.example.com/feed.xml&quot;</span><span class="kw">&gt;</span></a></code></pre></div> +<h3 id="conclusion">Conclusion</h3> +<p>As you can see, RSS really isn’t that complicated. You can get up and running with a feed for your site in less than a half-hour. It’s not even that hard to write it by hand, though that will get tedious over time. In the next post, I’ll talk about how I automate updates to my RSS feed and show you that it’s also really simple to automate updating the feed.</p> +<p>To learn more about available tags and what is and is not encouraged in RSS feeds, see the <a href="https://www.rssboard.org/rss-profile">RSS Best Practices Profile</a>.</p> +<p><em>This is my forty-ninth post for the <a href="https://social.paritybit.ca/tags/100DaysToOffload">#100DaysToOffload</a> challenge. You can learn more about this challenge over at <a href="https://100daystooffload.com" class="uri">https://100daystooffload.com</a>.</em></p>]]></description> + </item> +<item> <title>How to Create an RSS Feed for Your Blog – Part 1 — Why?</title> <link>https://www.paritybit.ca/blog/how-to-create-an-rss-feed-for-your-blog-1</link> <guid>https://www.paritybit.ca/blog/how-to-create-an-rss-feed-for-your-blog-1</guid> diff --git a/public/sitemap.xml b/public/sitemap.xml @@ -3,6 +3,7 @@ <url><loc>https://www.paritybit.ca</loc></url> <url><loc>https://www.paritybit.ca/home</loc></url> <url><loc>https://www.paritybit.ca/blog</loc></url> + <url><loc>https://www.paritybit.ca/blog/how-to-create-an-rss-feed-for-your-blog-2</loc></url> <url><loc>https://www.paritybit.ca/blog/how-to-create-an-rss-feed-for-your-blog-1</loc></url> <url><loc>https://www.paritybit.ca/blog/my-beginnings-with-gentoo</loc></url> <url><loc>https://www.paritybit.ca/blog/my-new-t420s</loc></url>