Blog·Tanky WooABOUTTAGSRSS

正如上一篇 从Octopress换到Jekyll 最后提到的,Jekyll没有RSS输出。

不过增加RSS功能并不麻烦,Github上已经有轮子了。

我只使用了其中的 feed.xml ,其余的对我作用不大。

{% raw %}
{{ site.name</td> </tr> <tr> <td><description>{% if site.description %}{{ site.description</td> </tr> <tr> <td><link>{{ site.url }}</link></td> </tr> <tr> <td><atom:link href="{{ site.url }}/feed.xml" rel=“self” type=“application/rss+xml” /></td> </tr> <tr> <td>{% for post in site.posts limit:10 %}</td> </tr> <tr> <td><item></td> </tr> <tr> <td><title>{{ post.title</td> </tr> <tr> <td>{% if post.author.name %}</td> </tr> <tr> <td><a href="dc:creator">dc:creator</a>{{ post.author.name</td> </tr> <tr> <td>{% endif %}</td> </tr> <tr> <td>{% if post.excerpt %}</td> </tr> <tr> <td><description>{{ post.excerpt</td> </tr> <tr> <td>{% else %}</td> </tr> <tr> <td><description>{{ post.content</td> </tr> <tr> <td>{% endif %}</td> </tr> <tr> <td><pubDate>{{ post.date</td> </tr> <tr> <td><link>{{ site.url }}{{ post.url }}</link></td> </tr> <tr> <td><guid isPermaLink="true">{{ site.url }}{{ post.url }}</guid></td> </tr> <tr> <td></item></td> </tr> <tr> <td>{% endfor %}</td> </tr> <tr> <td></channel></td> </tr> <tr> <td></rss></td> </tr> <tr> <td>{% endraw %}</td> </tr> </tbody> </table> <p>把这个文件放到整个Jekyll目录的根下,然后编辑<code>_config.yml</code>,增加如下字段:</p> <pre><code>name: "Blog · Tanky Woo" description: "Tanky Woo's Blog, focus on Python, Linux, Gentoo, Mac OS, Vim, Open Source and so on." url: "http://blog.tankywoo.com" </code></pre> <p>然后在<code>_layouts/default.html</code>的<code><head></code>里增加:</p> <pre><code>{% raw %} <link rel="alternate" type="application/rss+xml" title="{{ site.name }}" href="{{ site.url }}/feed.xml"> {% endraw %} </code></pre> <p>增加上面一行可以使RSS阅读器找到RSS文件的位置。</p> <p>然后重新生成静态输出就可以了。</p> </div> </div> <div class="push"> </div> </div> <div class="footer"> <p>Copyright © 2013-2021 | <a href="https://beian.miit.gov.cn">京ICP备16016622号-2</a> | Powered by <a href="https://gohugo.io/" target="_blank">Hugo</a>.</p> </div> <script type="text/javascript"> var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://"); document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3F6f8eefe3f13b327ada7a7406d2af3232' type='text/javascript'%3E%3C/script%3E")); </script> </body> </html>