How to install, use, and uninstall Jekyll

Source: Internet
Author: User

How to install, use, and uninstall Jekyll
How to install, use, and uninstall Jekyll

Recently, Jekyll was used to launch a website on Github. It took several days to get to know about Jekyll. Now we will share with you how to install, use, and uninstall Jekyll.

Jekyll is a simple website static page generation tool. Because it is written in Ruby, the configuration on Windows is a little complicated. The main steps are as follows:

Installation Method

Download the installation package from rubyinstalll and install it on a disk, such as E: \ Ruby193. Check all the options on the installation page (do not ask me why). decompress the downloaded DevKit to a directory, for example, E: \ devit

Note: When installing DevKit, it is best to create a folder named devit in the installation directory and then run the installer to select the folder.

Go to the devit installation directory in the git bash environment and run the following command:

cd /E/devitruby dk.rb init

Generate a config. yml configuration file, which contains the preceding Ruby installation directory E: \ Ruby193 (The system will automatically help you find the Ruby installation directory,cat config.ymlWe can see that the absolute path of the ruby directory has been written to this file.).

Runruby dk.rb install.

Last Run Commandgem install jekyllEnd the entire process

Check whether the installation is successfuljekyll -v

Brief Introduction

Before talking about how to use it, it is necessary to briefly introduce Jeklly and how Jeklly works. These core concepts can solve some of your doubts, help you gain a deeper understanding, and lay a foundation for later learning how to use templates, so as not to debug in the sky when an error occurs..

Skip this section if you just want to understand or know how to use jeklly.

What is Jeklly?

Jekyll is a ruby gem you install on your local system. Once there you can calljekyll --serverOn a directory and provided that directory is setup in a way jekyll expects, it will do magic stuff like parse markdown/textile files, compute categories, tags, permalinks, and construct your pages from layout templates and partials.

Once parsed, Jekyll stores the result in a self-contained static _ site folder. The intention here is that you can serve all contents in this folder statically from a plain static web-server.

Jeklly is a static site builder that generates static files based on the source code of the webpage. It provides templates, variables, plug-ins, and other functions, so it can be used to compile the entire website.

How does Jeklly work?

After installing jeklly, You need to organize your directory in a way that jeklly can recognize.

It requires that you use the following directory structure:

.|-- _config.yml|-- _includes|-- _layouts|   |-- default.html|   |-- post.html|-- _posts|   |-- 2011-10-25-open-source-is-good.markdown|   |-- 2011-04-26-hello-world.markdown|-- _site|-- index.html|-- assets    |-- css        |-- style.css    |-- javascripts
  • _ Config. yml:
    Configuration file data

  • _ Regiondes
    This folder is for partial views.

  • _ Layouts
    This directory mainly contains templates. You can use different templates for different pages.

  • _ Posts
    This directory contains your post and must follow the format@YEAR-MONTH-DATE-title.MARKUP@To name

  • _ Site
    This directory will be used to store static websites generated by Jekyll.

  • Assets
    This directory does not belong to the standard structure of Jekyll. It represents any directory that you want to place in the root directory and is ignored by Jekyll.

(Read more: https://github.com/mojombo/jekyll/wiki/Usage)

How to Use Jekyll to generate the final static file

Take the bootstrap template as an example to briefly describe how to quickly build a website.

Download the Jekyll-bootstrap template project to the local directory jekyll

git clone https://github.com/plusjade/jekyll-bootstrap.git demo

cd jekyllGo to the directory,jekyll serveStart the service

Open your browser and enter http: // localhost: 4000/in the address bar to view the following homepage:

Write new articles

Generate a new article using commands

gdw@GDW-PC /E/Git/demo (master)$ rake post title="My first blog"Creating new post: ./_posts/2015-02-11-my-first-blog.md

You can find the file in the _ posts directory and edit the content with Markdown.

You can also directly place the edited article in The _ posts directory, but you must use it at the beginning of the edited article.YAML Front Matter.The template, article, and page must provide YAML Front Matter so that Jekyll can understand how to handle your article.

YAML Front Matter in the following format must be provided at the beginning of the template/article/Page

---layout: postcategory : pagestags : [how-to, jekyll]---... contents ...
Compile a new page

Generate a new page using commands

gdw@GDW-PC /E/Git/demo (master)$ rake page name="about.md"mkdir -p .Creating new page: ./about.mdgdw@GDW-PC /E/Git/demo (master)$ rake page name="pages/about"mkdir -p ./pages/aboutCreating new page: ./pages/about/index.html
Uninstall Jekyll

It is difficult to install and configure Jekyll, but it is extremely simple to uninstall. Just one sentence

gem unistall jekyll

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.