静态站点的 RSS

发布于 2024-12-04 10:54:34 字数 349 浏览 0 评论 0原文

我有一个网站 deanvmc.me,我用它来自学 HTML、CSS 和 JavaScript。该网站故意保持静态,以将我的学习内容精简到只剩骨头(我认为这是最好的学习方式)。我使用 github 作为主机来进一步锁定静态生成的内容。

我想在此网站上放置一些文章和教程,并且认为为两者提供 RSS 源会很好。 /Articles 和 /Tutorials 目录将分别以 /Articles/ 和 /Tutorials/ 的形式列出实际帖子的内容。

我环顾四周,但我发现的任何教程似乎都依赖于我使用主要 CMS 引擎之一,而我不知道该怎么做。

我的理解是 RSS 的存在时间比 CMS 引擎还要长,所以我的问题是,是否可以联合我的静态站点?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

薆情海 2024-12-11 10:54:34

我为我的博客使用静态站点生成器(alexanderle.com)并遇到了这个问题。

我决定从头开始创建一个 RSS 提要,效果非常好!如果您有权访问模板系统或数据库,那么自动化也很容易。编辑 XML 一点也不困难 - 如果您可以编写简单的 HTML,则可以编辑 RSS XML 文件。

查看指南:https://alexanderle.com/create-an-rss -从头开始

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!

甜扑 2024-12-11 10:54:34

对于静态站点来说,获取 RSS 提要有点困难,因为您最终可能会重复内容,除非您准备好向站点生成中添加另一个工具,或者进行一些编程(并且可能使用与当前站点不同的语言)。 正如@Simone 所提到的,RSS 是一种简单的

格式并且易于编写。但是,如果您只是在当前正在做的事情之上编写 RSS 提要,那么您显然会复制部分或全部网站内容,这并不理想。

因此,我建议您需要一种获取内容并将其转换为 RSS 提要的方法,反之亦然。

当我使用 RSS 源创建静态内容网站时,我的做法是从 RSS 源开始。然后我编写了一些代码,这些代码将获取 RSS 提要并从中创建我的 HTML 文章 —— 在我的例子中,我使用 XSLT 将 RSS 转换为一系列 HTML 文件,但您可以使用任何您想要的技术。

然后,每当我想向我的静态站点添加一篇文章时,我都会编辑 RSS 提要,只是为了添加带有新日期等的新文章(并且有适用于各种平台的工具用于手动创建 RSS 提要)像这样。)然后我会运行我的代码,这会“烧毁”我的 HTML 文章,因此我总是会得到彼此一致的静态文章和 RSS 提要,并且只有一个“源”副本内容。

还有适用于各种平台的工具,可以自动或半自动地从磁盘上的一堆内容生成 RSS 提要,这是从另一个方向解决问题的一种方法。

因此,我的答案是,除非您准备将 CSS、HTML 和 Javascript 之外的其他语言或工具添加到您的技能库中,否则没有非常令人满意的方法来将 RSS 提要添加到静态站点。例如,如果您只是将其添加为手动生成的静态文件,那么您必须在两个位置更新内容。

您还可以通过了解现代 RSS 友好的静态网站创建工具 - Jekyll< /a> 或其更智能的衍生产品 Octopress,例如 - 完成这项工作。

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.

话少心凉 2024-12-11 10:54:34

RSS 只是一个遵循某些特定约定的 XML 文件。您可以手动编写 XML,但这项任务很乏味,尤其是当您的站点每天发布大量更改时。这就是 RSS 文件通常由 CMS 生成的原因。

在这里您可以找到 RSS 2.0 规范。

这是一个非常简单的 RSS 文件。

<?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>

每个items对应于提要中的一个条目。

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.

空城缀染半城烟沙 2024-12-11 10:54:34

是的,您可以为任何网站提供 RSS 提要,但最好是您不时添加或更改的网站。

只需编写 XML 文件,例如使用 RSS 2.0 并上传即可。

将元标记添加到网页的头部。

<link rel="alternate" type="application/rss+xml" title="My Test Feed" href="http://www.mysite.com/rss.xml" />

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" />
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文