Windows environment Jekyll + Github build personal blog

Meng to say something about how to use the new Jekyll build personal blog, from installation to configuration! Chicken details! . Original address https: //zhangmingemma.github ....

Introduction

jekyll is a static site generator generates static files based on page source code.

  • simple. No database, the comments feature is not required constantly updated version, only pay attention to your blog content
  • Static. Only Markdown (or Textile), Liquid , HTML & CSS you can build a static website that can be deployed
  • Blog form. Custom address, category page, blog content classification and custom layout design
  • Use GitHub Pages can run jekyll, very simple can be completely free of publishing site on GitHub

Environment Configuration

  1. Registration Github account and create a new warehouse tutorial first part, you can follow suit
  2. Download and install Git , git for Windows , installation tutorial
  3. Installation & Devkit Ruby , under Window system, we can use RubyInstaller to install Ruby environment, Download , installation tutorial
  4. Configuration jekyll environment (provided that your computer has a Python, easy_install)

Installation jekyll

$ gem install jekyll     

Create a blog

$ jekyll new myBlog    

Enter the blog directory

$ cd myBlog  

Start Local Service

$ jekyll serve

Enter in the browser: HTTP: // localhost: 4000 , you can see the effect of your blog.

Error: Auto-regeneration: enabled for 'c:/Devkit/MyBlog'
Configuration file: c:/Devkit/MyBlog/_config.yml
jekyll 3.4.1 | Error:  Permission denied - bind(2) for 127.0.0.1:4000

* Solution: turn off the background turned Apache, MySQL service, restart jekyll serve, continue error, then added port in _config.yml file the last line: 4001

Directory Structure

 
Jekyll core is actually a text transformation engine. Its concept is actually: you use your favorite markup language used to write articles that can be Markdown, can also be a Textile, or just simple HTML, and then Jekyll will help you set into one or a series of layout. Throughout the process, you can set the URL path, your text appears in the layout style, and so on. These can be achieved through a plain text editor, and ultimately generate static pages is your finished product.

A basic directory structure Jekyll website is generally like this:

.
├── _config.yml
├── _includes
|   ├── footer.html
|   └── header.html
├── _layouts
|   ├── default.html
|   ├── post.html
|   └── page.html
├── _posts
|   └── 2016-10-08-welcome-to-jekyll.markdown
├── _sass
|   ├── _base.scss
|   ├── _layout.scss
|   └── _syntax-highlighting.scss
├── about.md
├── css
|   └── main.scss
├── feed.xml
└── index.html

The directory structure and the specific role can refer to the official website of documents

_Config.yml into the inside, to modify the information you want to see re-jekyll server, refresh the browser you can see the information you just modified.

This, blog set up initially be done,

Blog deploy to the remote

Create a folder on the local blog, open git bash within the folder, run the command

$ git clone https://github.com/(github的用户名)/(github的仓库名).git

You can see more folders within folders (github repository name) .git (containing hidden in READme .git folders and files)

All of them move to the next blog directory and all contents _config.yml, _layouts, _posts and other documents under the blog you created locally, delete the (github repository name) .git folder

Run command

git add .
git commit -a -m "first commit"
git remote add origin https://github.com/(github用户名)/(github仓库名).git
git push -u origin master

If you are bound to a domain name:

  1. First, create a file called CNAME in the project root directory, which is written on their own as well as a domain name (such as this blog is skyinlayer.com)
  2. An increase in DNS A record for your domain name, point to 207.97.227.245
  3. The project submitted to the github, wait a minute (not more than one hour)
  4. baseurl should be "/"
  5. Access to your domain name to see the results of it

If it is bound to two domain names, a CNAME need additional, point (github username) .github.io in DNS, CNAME and then modify the file to your secondary domain name

Writing articles

All articles are _posts directory, article format mardown format, the file name can be .mardown article or .md.

Write a new article is very simple, you can copy it directly from the _posts / directory 2016-10-16-welcome-to-jekyll副本.markdown, change the name to 2016-10-16-article1.markdown, NOTE: The preceding article name must be in the 2016-10-16- date can be modified, but must be a year - month - day - format, is connected behind article1 URL entire article, if the article titled Chinese, then the connection URL of the article will become this: HTTP: // Baixin. IO / 2015/08 / E6% ...% , it is proposed that the article is the best name in English or Arabic numerals. Double-click to open 2016-10-16-article1.markdown


---
layout: post
title:  "Welcome to Jekyll!"
date:   2016-10-16 11:29:08 +0800
categories: jekyll update
---

正文...

article name display, such as:: title title: my first post
articles published date display, such as:: DATE DATE: 2016-10-16
the Categories: Categories tag labels, such as: categories: Essay

Note: The article header format must be above .... is the text content of the article.

I wrote articles using Sublime Text3 editor, Markdown syntax is simple

Use the blog template

Although the blog deployment is complete, you will find the blog too simple not what you want, there are a lot of beautiful templates .

Choose your favorite template download extract to a directory, the _config.yml, _posts modified to their own information and articles, use the command to deploy local services

$ jekyll server   

There may be some errors:

/Users/xxxxxxxx/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- bundler (LoadError)
    from /Users/xxxxxxxx/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /Users/xxxxxxxx/.rvm/gems/ruby-2.2.2/gems/jekyll-3.3.0/lib/jekyll/plugin_manager.rb:34:in `require_from_bundler'
    from /Users/xxxxxxxx/.rvm/gems/ruby-2.2.2/gems/jekyll-3.3.0/exe/jekyll:9:in `<top (required)>'
    from /Users/xxxxxxxx/.rvm/gems/ruby-2.2.2/bin/jekyll:23:in `load'
    from /Users/xxxxxxxx/.rvm/gems/ruby-2.2.2/bin/jekyll:23:in `<main>'
    from /Users/xxxxxxxx/.rvm/gems/ruby-2.2.2/bin/ruby_executable_hooks:15:in `eval'
    from /Users/xxxxxxxx/.rvm/gems/ruby-2.2.2/bin/ruby_executable_hooks:15:in `<main>'

The reason: There is no installation bundler, execute the command to install bundler

$ gem install bundler

prompt:

Fetching: bundler-1.13.5.gem (100%)
Successfully installed bundler-1.13.5
Parsing documentation for bundler-1.13.5
Installing ri documentation for bundler-1.13.5
Done installing documentation for bundler after 5 seconds
1 gem installed

$ Jekyll server to perform again, suggesting


Could not find proper version of jekyll (3.1.1) in any of the sources
Run `bundle install` to install missing gems.

Follow the prompts run the command

$ bundle install

prompt

Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/..
Fetching dependency metadata from https://rubygems.org/.
。。。
Installing jekyll-watch 1.3.1
Installing jekyll 3.1.1
Bundle complete! 3 Gemfile dependencies, 17 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.

bundler installation is complete, start local service again

$ jekyll server

Continue error

Configuration file: /Users/tendcloud-Caroline/Desktop/XXXXXXXXXXXXX/_config.yml
  Dependency Error: Yikes! It looks like you don't have jekyll-sitemap or one of its dependencies installed. In order to use Jekyll as currently configured, you'll need to install this gem. The full error message from Ruby is: 'cannot load such file -- jekyll-sitemap' If you run into trouble, you can find helpful resources at http://jekyllrb.com/help/! 
jekyll 3.1.1 | Error:  jekyll-sitemap

Represents jekyll-sitemap is not installed gem of

gem install jekyll-sitemap

And added Gemfile

gem 'jekyll-sitemap', '~> 1.0'

Start the local service again

$ jekyll server

prompt

Configuration file: /Users/baixinpan/Desktop/OpenSource/Mine/Page-Blog/XXXXXXXXXXXXX/_config.yml
            Source: /Users/baixinpan/Desktop/OpenSource/Mine/Page-Blog/XXXXXXXXXXXXX
       Destination: /Users/baixinpan/Desktop/OpenSource/Mine/Page-Blog/XXXXXXXXXXXXX/_site
 Incremental build: disabled. Enable with --incremental
      Generating... 
                    done in 0.901 seconds.
 Auto-regeneration: enabled for '/Users/baixinpan/Desktop/OpenSource/Mine/Page-Blog/XXXXXXXXXXXXX'
Configuration file: /Users/baixinpan/Desktop/OpenSource/Mine/Page-Blog/XXXXXXXXXXXXX/_config.yml
    Server address: http://127.0.0.1:4000/
  Server running... press ctrl-c to stop.

Indicates that the local service deployment success.

In the browser input 127.0.0.1:4000 , you can see the effect of the blog.

Guess you like

Origin www.cnblogs.com/homehtml/p/12208530.html