The magazine of the B6sicS SCHooL

Jekyll's blogging

12 Apr 2020 - Kovacs J Giulia

In true Jekyll style, blogging is powered by text files only.
Blog posts live in a folder called  _posts . The filename for posts have a special format: the publish date, then a title, followed by an extension. Sample post ( _posts/2020-04-04-bananas.md ):


    ---
    layout: post
    author: emi
    ---
    A banana is an edible fruit.  

    In some countries, bananas used for cooking may be called "plantains",
    distinguishing them from dessert bananas.
    

The post layout you’ll need to create it at  _layouts/post.html  with the following content:


    ---
    layout: default
    ---
    <h1>{{ page.title }}</h1>
    <p>{{ page.date | date_to_string }} - {{ page.author }}</p>
    {{ content }}
    

Jekyll makes posts available at  site.posts .
Create  blog.html  in the root with the following content:


    ---
    layout: default
    title: Blog
    ---
    <h1>Latest Posts</h1>

    <ul>
      {% for post in site.posts %}
        <li>
            <h2>
                <a href="{{ post.url | relative_url }}">
                    {{ post.title }}
                </a>
            </h2>
          {{ post.excerpt }}
        </li>
      {% endfor %}
    </ul>
    

Open  _data/navigation.yml  and add an entry for the blog page:


    - name: Home
      link: /
    - name: About
      link: /about.html
    - name: Blog      
      link: /blog.html
    
jekyll