Jekyll'a RSS Feed Nasıl Eklenir?

Hugo için rss-feed-in-hugo yazısını paylaştıktan sonra fark ettim ki jekyll için yazmamışım. İki yol göstereceğim, birincisi eklenti ile ikincisi liquid kodu ile.

Yöntem I: Plugin

Eklenti ile yapmak oldukça kolay. Gemfile’ınıza gem 'jekyll-feed' satırını ekleyin ve _config.yml dosyasına ise aşağıdaki satırları ekleyin.

plugins:
  - jekyll-feed

Böylece, jekyll-feed pluginini eklemiş olacaksınız ve plugin bizim için /feed.xml dosyasını oluşturacak. Pluginin ayarlarını değiştirmek isteyebilirsiniz, varsayılan olarak son 10 postu alacaktır. Github sayfasında değiştirebileceğimiz parametreler detayları ile var.

Yöntem II: Liquid

İkinci yöntemde ise, eklenti kullanmadan liquid templati oluşturacağız. Root dizininde /feed.xml dosyasını oluşturduktan sonra aşağıdaki kodu yapıştırabilirsiniz veya istediğiniz gibi düzenleyebilirsiniz.

---
layout: none
---
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>{{ site.title | xml_escape }}</title>
    <author><name>{{ site.author.fullname | xml_escape }}</name></author>
    <description>{{ site.description | xml_escape }}</description>
    <link>{{ site.author.url }}</link>
    <atom:link href="/feed.xml" rel="self" type="application/rss+xml" />
    {% for post in site.posts limit:45 %}
      <item>
        <title>{{ post.title | smartify | strip_html | normalize_whitespace | xml_escape }}</title>
        <category>{{ post.category | xml_escape }}</category>
        <author>{{ site.author.fullname | xml_escape }}</author>
        <description>{{ post.content | strip | xml_escape }}</description>
        <pubDate>{{ post.date | date: "%a, %d %b %Y %H:%M:%S %z" }}</pubDate>
        <link>{{ site.author.url | append: "/" | append: post.url | xml_escape }}</link>
        <guid>{{ site.author.url | append: "/" | append: post.url | xml_escape }}</guid>
      </item>
    {% endfor %}
  </channel>
</rss>

Next Episode

published on 10.11.2018

Run jekyll site: jekyll serve If you have gem files use the below code instead: bundle exec jekyll serve Parameters Usage -o open the site in browser -w watch –port port, to run multiple sites locally. jekyll serve -o -w --port 8000 jekyll serve -o -w --port 4000 This way you can run more than …

Previous Episode

published on 27.01.2019

Sitemap, sitemap.xml dosyası, bir websitesinin içeriğinin gösterildiği modeldir. URL’lerden oluşur. Search enginelerin crawl botlarla siteyi dolaşabilmelerine yardımcı olur. Sitemap, crawler’ın tüm sayfaları indexleyeceğini garantilemez; ancak yine de büyük arama motorları sitemap …

TAG CLOUD