RSS for a static site
Asked Answered
I

4

9

I have a site, deanvmc.me that I am using to teach myself HTML, CSS and JavaScript. The site is purposely static to strip my learning down to bear bones (The best way to learn I feel). I am using github as the host to further lock me down to statically generated content.

I would like to place some articles and tutorials on this site and feel that it would be nice to offer an RSS feed for both. The /Articles and /Tutorials directories will be used to list the content with the actual posts in the form of /Articles/ and /Tutorials/ respectively.

I have looked around but any tutorial I have found seems to rest upon me using one of the major CMS engines, which I do not what to do.

My understanding is RSS has been around longer than CMS engines, so my question is, is it possible to syndicate my static site?

Inference answered 13/9, 2011 at 10:28 Comment(0)
C
7

It's a little tougher with static sites to get an RSS feed, because you can end up duplicating content unless you're prepared to add another tool to your site generation, or do a little bit of programming (and probably in a language different from the ones you're currently using.)

As @Simone has mentioned, RSS is a simple format and easy to write. But if you just write an RSS feed on top of what you're doing right now, you'll obviously be duplicating some or all of the site content, which isn't ideal.

So, I'd suggest that what you need is a way of taking your content and transforming it into an RSS feed -- or vice versa.

When I created a static-content site with an RSS feed, the way I did it was to start with the RSS feed. Then I wrote some code that would take the RSS feed and create my HTML articles from it -- in my case I used XSLT to transform the RSS into a series of HTML files, but you could use any technology you want.

Then, whenever I wanted to add an article to my static site, I'd edit the RSS feed just to add a new article with a new date, etc. to it (and there are tools around for various platforms for creating RSS feeds manually like this.) Then I'd run my code, which would "burn" my HTML articles, so I'd always end up with static articles and an RSS feed in line with each other, and only one "source" copy of the content.

There's also tools out there for various platforms that can automate or semi-automate generating an RSS feed from a bunch of stuff on disk, which is a way of approaching the problem from the other direction.

My answer, therefore, is that unless you're prepared to add another language or tool apart from CSS, HTML and Javascript to your repertoire, there's no very satisfactory way to add an RSS feed to a static site. If you just add it as a static file generated manually, then you have to update your content in two places if you edit an article, for example.

You might also learn a lot from having a look at how the modern crop of RSS-friendly static site creation tools -- Jekyll, or its smarter derivative Octopress, for example -- do the job.

Cyanine answered 13/9, 2011 at 10:47 Comment(0)
T
9

I use a static site generator for my blog (alexanderle.com) and ran into this problem.

I decided to created an RSS feed from scratch and it works great! Pretty easy to automate too if you have access to the template system or database. Editing the XML is not that difficult at all - if you can write simple HTML, you can edit a RSS XML file.

Check out the guide at https://alexanderle.com/create-an-rss-feed-from-scratch!

Tref answered 12/4, 2012 at 15:28 Comment(0)
C
7

It's a little tougher with static sites to get an RSS feed, because you can end up duplicating content unless you're prepared to add another tool to your site generation, or do a little bit of programming (and probably in a language different from the ones you're currently using.)

As @Simone has mentioned, RSS is a simple format and easy to write. But if you just write an RSS feed on top of what you're doing right now, you'll obviously be duplicating some or all of the site content, which isn't ideal.

So, I'd suggest that what you need is a way of taking your content and transforming it into an RSS feed -- or vice versa.

When I created a static-content site with an RSS feed, the way I did it was to start with the RSS feed. Then I wrote some code that would take the RSS feed and create my HTML articles from it -- in my case I used XSLT to transform the RSS into a series of HTML files, but you could use any technology you want.

Then, whenever I wanted to add an article to my static site, I'd edit the RSS feed just to add a new article with a new date, etc. to it (and there are tools around for various platforms for creating RSS feeds manually like this.) Then I'd run my code, which would "burn" my HTML articles, so I'd always end up with static articles and an RSS feed in line with each other, and only one "source" copy of the content.

There's also tools out there for various platforms that can automate or semi-automate generating an RSS feed from a bunch of stuff on disk, which is a way of approaching the problem from the other direction.

My answer, therefore, is that unless you're prepared to add another language or tool apart from CSS, HTML and Javascript to your repertoire, there's no very satisfactory way to add an RSS feed to a static site. If you just add it as a static file generated manually, then you have to update your content in two places if you edit an article, for example.

You might also learn a lot from having a look at how the modern crop of RSS-friendly static site creation tools -- Jekyll, or its smarter derivative Octopress, for example -- do the job.

Cyanine answered 13/9, 2011 at 10:47 Comment(0)
H
3

The RSS is just an XML file that follows some specific conventions. You can write the XML manually, but the task is tedious, especially if your site publishes lots of changes every day. This is the reason why the RSS file is normally generated by your CMS.

Here you can find the RSS 2.0 specification.

Here's a very simple RSS file.

<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
  <title>RSS Title</title>
  <description>This is an example of an RSS feed</description>
  <link>http://www.someexamplerssdomain.com/main.html</link>
  <lastBuildDate>Mon, 06 Sep 2010 00:01:00 +0000 </lastBuildDate>
  <pubDate>Mon, 06 Sep 2009 16:45:00 +0000 </pubDate>

  <item>
    <title>Example entry</title>
    <description>Here is some text containing an interesting description.</description>
    <link>http://www.wikipedia.org/</link>
    <guid>unique string per item</guid>
    <pubDate>Mon, 06 Sep 2009 16:45:00 +0000 </pubDate>
  </item>
</channel>
</rss>

Each items corresponds to an entry in the feed.

Hett answered 13/9, 2011 at 10:34 Comment(0)
E
2

Yes you can have an RSS feed for any site, but preferably for one that you are adding or changing from time to time.

Just write the XML file, e.g. using RSS 2.0 and upload it.

Add the meta tag to the head of your web page.

<link rel="alternate" type="application/rss+xml" title="My Test Feed" href="http://www.mysite.com/rss.xml" />
Eschatology answered 13/9, 2011 at 10:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.