Using Jekyll to create a gitpage on windows

Understanding Jekyll, Gem, Bundle, Ruby

what is Ruby

:hear_no_evil:

Ruby is a dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write.

Ruby is most used for building web applications. However, it is a general-purpose language similar to Python, so it has many other applications like data analysis, prototyping, and proof of concepts.

What is a Ruby gem?

A gem is a package that you can download & install. When you require an installed gem you’re adding extra functionality to your Ruby program.

What Is Bundler?

While learning about Ruby gems you may also read about Bundler. But what is Bundler exactly? Bundler is a tool for dependency management. Didn’t RubyGems already handle this? Well, it does… but only for the gems themselves. Your regular Ruby application isn’t built as a gem, so it doesn’t get this feature. That’s why Bundler exists!

Bundler (and RubyGems since version 2.0) can read Gemfile & install the requested versions of the gems.

  1. gem 'rails', '~> 5.2.1'
  2. gem 'puma', '~> 3.11'

TODO:

  • what is gem
  • what is Bundle
  • What is Jekyll

Using jekyll to create a “Hello world” post

  • Install Ruby, Gem
  • Using Gem to install Jekyll, Bundler, Wdm, Webrick: gem install jekyll bundler wdm webrick
  • Create a directory to deposite your personal website: mkdir docs, cd docs
  • Create Gemfile to list project’s dependencies: bundle init
  • Modify Gemfile by adding:
    • gem "jekyll"
    • gem webrick
    • gem 'wdm', '>= 0.1.0' if Gem.win_platform?
  • Create your site by creating an index.html
  • Write something:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    
    <html>
    <head>
        <meta charset="utf-8">
        <title>Home</title>
    </head>
    <body>
        <h1>Hello World!</h1>
    </body>
    </html>
    
  • bundle install to install all gem packages from “Gemfile”.
  • Create local site: jekyll serve

Some notes

  • _drafts folder deposits posts that you are not ready to publish. Once they are ready, move them to _posts folder. To view the drafts, use the command jekyll serve --drafts
  • Add page: change layout to page
  • Add permalink: permalink: /:categories
  • Add defaults front matter to _config.yml:
    1
    2
    3
    4
    5
    6
    7
    8
    
    defaults:
      -
        scope:
        path: "" #which file to apply to, empty->all files
        type: "post" #aplly to all posts
        values:
          layout: "post"
          title: "my title"
    
  • Change a theme: in Gemfile, add theme: theme-name
  • _layouts folder contains layout html files. The name of the layout is the file name. If wanna use them, just change the layout variable in your front matter.
  • different level layouts embedding.
  • Access variable by {{ variable }}
  • Include: header, footer or navigation: { include header.html }

change a theme