Atilla Tanrikulu

I am an experienced software engineer and architect living in Germany. I’m passionate about distributed scalable enterprise web-based microservices/applications and delivering great user experiences. I have created some amazing enterprise-level applications that many people have used and hopefully enjoyed.

Articles

Java Quick Reference Apache Kafka Tutorial Guvenli Kod Gelistirme Making an Enterprise Scale Angular Project Step by Step Nightly SQL Server Database Backup with command line batch file and windows scheduler AOP Framework without proxy pattern IdentityServer Nedir Middleware Pattern With Csharp And Javascript Docker most used commands Online Proje Dokumantasyonu, Docker, Nginx, mdwiki How to use Github Pages for static websites Inheritance with JavaScript, EC6 (ECMAScript 6, ECMAScript 2015) Object oriented javascript and Inheritance Singleton Pattern with Javascript Factory Pattern with Javascript Open terminal here mac os x service IdentityServer4-Angular-6-integration JMater notlari, kurulum ve kullanim Learn Jekyll in 12 Steps Make Mac Application with Automater from sh script Make spotlight index markdown or code files OAuth 2.0 Nedir (RFC6749) Using Custom CSS and Custom JavaScript to an Angular Project Cross Platform Desktop Application With .Net Core 2x and Angular 6x front-end projects with nodejs gulp bower yeoman and angularjs Host Asp.Net Core on Linux with Apache Redis kurulumu ve ayarlari Useful Mac OS Apps Choosing internet connection on multiple interface windows Name Server Kurulumu How to define domain name for your dynamic IP SQL table data compare, and prepare insert satements Useful Git Commands TFS ile Otomatik deployment yapmak Spring Boot Tutorial Sql server icin maliyetli sorgularin tespit edilmesi Arama Motoru Optimizasyonu (SEO) My installed mac apps

Learn Jekyll in 12 Steps

Jekyll is a simple, blog-aware, static site generator perfect for personal, project, or organization sites. Think of it like a file-based CMS, without all the complexity. Jekyll takes your content, renders Markdown and Liquid templates, and spits out a complete, static website ready to be served by Apache, Nginx or another web server. Jekyll is the engine behind GitHub Pages, which you can use to host sites right from your GitHub repositories.

1. Installation

# update gem
$ sudo gem update --system
# install jekyll
$ sudo gem install jekyll

2. Create simple jekyll website and run

$ touch index.html
$ nano index.html

paste into some html.

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>my title</title>
  </head>
  <body>
    <h1>Test</h1>
  </body>
</html>
# create jekyll configuration file.
$ touch _config.yml

content of _config.yml

markdown: redcarpet
baseurl: /blog

run jekyll

$ jekyll serve
## further example
## jekyll serve --watch --baseurl ""
# navigate http://127.0.0.1:4000

navigate to http://127.0.0.1:4000/blog/

3. Layouts

Create _layouts folder in your website

# this is the special folder for jekyll
$ mkdir _layouts
$ cd _layouts
$ touch default.html
$ nano default.html

after paste below html

<html>
  <head>
    <meta charset="utf-8">
    <title>my title</title>
  </head>
  <body>
  {{content}}
  </body>
</html>

change your index.html like below

<h1>Test</h1>

note: You can extend layouts with sub layouts

4. Includes

Create _includes folder in your website

# this is the special folder for jekyll
$ mkdir _includes
$ cd _includes
$ touch nav.html
$ nano nav.html

create a new page named nav.html

<ul>
  <li><a href="{{site.baseurl}}/index.html">Ana sayfa</a></li>
  <li><a href="{{site.baseurl}}/news.html">Ana sayfa</a></li>
</ul>

and change your _layouts/default.html page like bellow

<!DOCTYPE html>
<html>
  <head>                                                                                                                                                                                                                                            
    <meta charset="utf-8">
  <title>my title</title>
  </head>
  <body>
  {% include nav.html %}

  {{content}}

  </body>
</html>

you can send variable to included page like below

  {% include nav.html type='active' %}
  # you can catch variable like below
  include.type

5. Css and if statement

Create css folder and add common.css Create _includes folder in your website

<ul>
  <li><a href="{{site.baseurl}}/index.html"  class="{% if page.url=='/index.html' %}current{% endif %}">Home</a></li>
  <li><a href="{{site.baseurl}}/news.html"  class="{% if page.url=='/news.html' %}current{% endif %}">News</a></li>
</ul>

# or contains condition
<ul>
  <li><a href="{{site.baseurl}}/index.html"  class="{% if page.url contains 'index.html' %}current{% endif %}">Home</a></li>
  <li><a href="{{site.baseurl}}/news.html"  class="{% if page.url=='/news.html' %}current{% endif %}">News</a></li>
</ul>

6. Posts

Create _posts folder in your website

# this is the special folder for jekyll
$ mkdir _posts
$ cd _posts
# file name is the special name for jekyll
$ touch 2017-01-01-First-Blog-Post.md
$ nano 2017-01-01-First-Blog-Post.md

put the html like below

<ul>
  {% for item in site.posts %}
<li>
  <a href="{{site.baseurl}}{{item.url}}">{{ item.title }}</a>
  <p>{{ item.meta }}</p>
</li>
  {% endfor %}
</ul>
# or specific category loop


<ul>
  {% for item in site.categories.news %}
<li>
  <a href="{{site.baseurl}}{{item.url}}">{{ item.title }}</a>
  <p>{{ item.meta }}</p>
</li>
  {% endfor %}
</ul>

# we can limit for loop like this
<ul>
  {% for item in site.posts limit:1%}
<li>
  <a href="{{site.baseurl}}{{item.url}}">{{ item.title }}</a>
  <p>{{ item.meta }}</p>
</li>
  {% endfor %}
</ul>

note: for collection items have a `.url` property, jekyll sets the `.url` property

7. Data

Create _data folder in your website

# this is the special folder for jekyll
$ mkdir _data
$ cd _data
# file name is the special name for jekyll
$ touch menu.yml
$ nano menu.yml

put the data like below

- title: menu1
  meta: meta1
  folder: menu
  content: 'Sample **markdown** text1'

- title: menu2
  meta: meta2
  folder: menu
  content: 'Sample **markdown** text2'

- title: menu3
  meta: meta3
  folder: menu
  content: 'Sample **markdown** text3'


end loop in your data

<ul>
  {% for item in site.data.news %}
<li>
  <a href="{{site.baseurl}}/menu/{{item.folder}}">{{ item.title }}</a>
  <p>{{ item.meta }}</p>
</li>
  {% endfor %}
</ul>

8. Pages

we can loop in site.pages

<ul>
{% for page in site.pages %}
{% if page.url contains 'html' and page.publish==true %}
<li><a href="{{site.baseurl}}{{page.url}}">{{page.title}}</a></li>
{% endif %}
{% endfor %}
</ul>

9. Using site.pages metadata in layouts

if you are using page variable in your page, you can use it in layout

page: page1.md

---
layout: default
title: page1 title
meta: page1 meta
publish: true
---

this is **markdown** text

layout: default.html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>{% if page.title %}{{page.title}} . {% endif %} - Common Title</title>
  <link rel="stylesheet" href="{{site.baseurl}}/css/common.css">
  </head>
  <body>
  {% include nav.html %}
  {{content}}
  </body>
</html>

note: If you put this

---
---

in some file, jekyll takes action for this file.

10. SiteMap.xml

sample sitemap.xml:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">

<url>
  <loc>http://....</loc>
  <changefreq>monthly</changefreq>
  <priority>0.5</priority>
</url>

</urlset>  

create _includes/sitemap-entry.xml

<url>
  <loc>http://..../{{site.baseurl}}{{include.entry.url}}</loc>
  {% if include.entry.changefreq %}
  <changefreq>{{include.entry.changefreq}}</changefreq>
  {% endif %}
  {% if include.entry.priority %}
  <priority>{{include.entry.priority}}</priority>
  {% endif %}
</url>

create your sitemap.xml in root path

---
---
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">

{% for page in site.pages %}
  {% if page.layout %}
    {% include sitemap-entry.xml entry=page %}
  {% endif %}
{% endfor %}

{% for post in site.posts %}
{% include sitemap-entry.xml entry=post %}
{% endfor %}

</urlset>

11. Pretty url

you can remove .html extension from your pages in the config _config.yml you can add permalink: pretty

sample config file:

markdown: redcarpet
baseurl: /blog
permalink: pretty

12. Collections

Collection is a folder that is contains pages, we can define our collection folder in config file like below

markdown: redcarpet
baseurl: /blog
permalink: pretty

collections:
  downloads:
    output: true
    permalink: /downloads/:path/


create _downloads folder in you root folder and put it blow files item1.md:

---
layout: default
title: Download item1
description: item1 description
---
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

item2.md:

---
layout: default
title: Download item2
description: item2 description
---
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

item1.md:

---
layout: default
title: Download item3
description: item3 description
---
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

and create downloads.html and loop these files.

Download example project

Explore the Jekyll plugins

Useful snippets

Further Steps

folder structure:

_data
  authours.yml
  language-en.yml
  language-tr.yml
  top-navigation.yml
  left-navigation.yml
  footer-socialmedia.yml
  footer-netwrok.yml
  dropdowns.yml
_drafsts
_includes
_posts
_layouts
assets
  css
  fonts
  img
  js

pages
feed.xml
sitemap.xml
index.md

Date: 2017-10-23 10:20:00 +0000