https://kevincox.ca/2022/05/06/rss-feed-best-practices/ Kevin Cox / 2022 / 05 / 06 / RSS Feed Best Practises RSS Feed Best Practises Posted on 2022-05-06 These are some technical tips for publishing a blog. These have nothing to do with good content, just how to share that content. The recommendations are roughly in order of importance and have rationale for why they are that important. Formats People generally call feeds "RSS Feeds" but usually they aren't specifically talking about RSS. RSS isn't the only, or even the best format. Using a standardized format is critical to your feed being understood by the widest variety of readers and search engines. You should use RSS 2 or Atom. These formats are very widely supported. Other common formats are earlier RSS standards and JSON Feed or Microformats h-feed. I would avoid using these--or even less common formats--as they are less widely supported. If you don't have a feed yet I would highly recommend Atom. The specification has much less ambiguity, so you are less likely to have compatibility issues with the wide variety of clients in use. The specification is also simpler and more clear overall. If you already have an RSS 2 feed there is little reason to upgrade. A minimal Atom template is below. For full details see the spec. If you need an example you can look at my feed. {{FEED_NAME}} {{HOMEPAGE_URL}} {{LAST_UPDATE_TIME in RFC3339 format}} {{AUTHOR_NAME}} {{ENTRY.TITLE}} {{ENTRY.PERMALINK}} {{ENTRY.FIRST_POST_TIME in RFC3339 format}} {{ENTRY.LAST_UPDATE_TIME in RFC3339 format}} {{ENTRY.HTML}} There is very little reason to provide feeds in multiple formats. If you have an Atom feed you don't need to provide an RSS feed as well. Changing feed format is safe. Very few readers will be confused if a feed switches between Atom and RSS. This can be done either by changing the feed at the same URL or by redirecting new a new URL. (Just be sure to update the content type) Content Type Be sure to set the Content-Type header properly. * Atom: Content-Type: application/atom+xml * RSS: Content-Type: application/rss+xml * JSON Feed: Content-Type: application/feed+json You will see other values used in the wild but these are the standard values and have the widest support. Absolute URLs Every URL in your feed should be absolute. While Atom has clearly specified how to resolve relative URLs they are rarely implemented correctly. In order to ensure that your feed can be understood by all readers use only absolute URLs (starting with https://). This includes all elements and the summary and body of posts (including in the HTML). Discovery On all of your blog pages and likely every page of your site you should include metadata to advertise you feed. This will allow readers and search engines to subscribe and become aware of your new content. This is as simple as providing the following in your HTML: If you have multiple feeds you can advertise them all with appropriate titles. Make sure that you use the correct type for your feed. The examples provided are for Atom feeds. Prefer to put the "most important" feed at the top. Many clients will preserve the order when presenting feeds to the user. This is subjective but typically would be a whole-site feed, then category feeds, then a comment feed for the specific page. You can validate that this is working correctly by putting your website URL into the W3C Feed Validation Service. If your links are set up correctly it should detect and validate your feed. Try out a few different pages to make sure that you have discovery working everywhere. Try your homepage, post lists page and an individual post page. If it is difficult to modify the HTML a Link header in the HTTP response can be used. However, this isn't as widely supported. Using HTML tags is preferred for wider compatibility. Link: /feed.atom; rel="alternate"; type="application/atom+xml" You should also include a link with an RSS logo rss logo for users without another feed indicator. HTTPS HTTPS is key to security and privacy on the internet. Providing feeds over HTTPS ensures user privacy and ensures that your feed is not modified by a malicious actor. 1. Reference all embedded media (such as images) over HTTPS. Many readers will run in a secure context where HTTP requests are not allowed. 2. Provide the feed over HTTPS. 3. Ensure that your self link is HTTPS. 4. Redirect HTTP requests to HTTPS. 5. Consider using Strict-Transport-Security. Full Content It is generally recommended to provide the full content of your posts in the feed. This is what most readers prefer. Atom has both element for readers that prefer it. For RSS and the Atom element the full article should be included. Of course sharing full content in feeds is unacceptable to some publications due to the difficulty of monetizing these views. First, consider that this may be a reader that would leave if they can't view the full content in their feed reader. Even if they don't see your ads they may share your content with friends or on news aggregators. Likely it is still more valuable for you to have this reader than to lose them. If your content is paid consider allowing users to generate private links by providing an auth token. For example /feed.atom?user= peruserauthtoken. You can also use basic auth like https:// fred:peruserauthtoken@blog.example/feed.atom however this is supported by fewer readers than providing a token in the URL path or query string. Entry IDs Entry IDs are the primary way to identify and differentiate different entries in your feed. If your entry IDs change or repeat, readers will miss entries or receive duplicate entries. 1. Never change your Entry IDs for an existing article. + If you change your ID scheme, ensure that it only applies to new entries. 2. Never reuse Entry IDs for different articles. 3. Prefer to use article permalinks for Entry IDs. 4. Prefer to make your Entry IDs globally unique across all feeds in existence. + Some readers will merge feeds together, unique IDs help ensure there are no issues. + The easiest way to accomplish this is to use a URL on a domain that you control. If that isn't possible you can use a UUID such as urn:uuid:f4a3ca5b-5799-44e8-aaaa-e40728f037d3. Dates Both Atom and RSS differentiate between time of publication (the time the entry first appeared in the feed) and the time of last update (the last time the entry was changed). Be sure to handle these correctly. 1. Include a publication time. 2. The publication time should never change. An entry can only be published once. 3. Prefer making the publication time roughly match when the entry appeared on the feed. Some readers will ignore entires that were published in the far past. Strongly avoid having entries appear in the feed in different orders than their publication time suggests. 4. Avoid future publication times. If a publication time is too far in the future many readers will ignore it as a bug. 5. Update time should be greater than or equal to the publication time. New entires should have these two be the same. 6. Update time should only change on significant updates. Slight formatting changes or typo fixes probably shouldn't change the last update time. Most readers ignore the update time, some will resurface your article as "updated". Styling Feel free to use CSS in your feed! However, keep in mind that many feed readers don't use modern browser engines and may be limited in what they can render. Additionally, many feed readers will sanitize your feed so uncommon elements and custom CSS may be partially or completely stripped. But don't let that stop you! Using HTML and CSS can greatly improve the experience for users with good readers. Consider the following tips: 1. Consider what will happen if any CSS doesn't apply. For example if you set background: black; color: white and one of the two rules is stripped you will have unreadable text. In generally prefer to make small adjustments rather than relying on CSS for dramatic changes. 2. Prefer inline CSS style attributes to separate