[Blog] on top of open source in Github a custom domain name Hexo blog

A. Configuration Environment

1. Download and install git

Download git link: https://git-scm.com/downloads
Note To select 32-bit or 64-bit correct.

2. Download and install Node.js

Node.js download link: http://nodejs.cn/download/
ibid select 32-bit or 64-bit.
After a successful installation, the input node -v and npm -v can see if the installation was successful.
Restart the computer .

3. Configure Hexo

1. Create a new folder, right-letter computer, click git base. Such as: D: \ Github \ HEXO
2. Enter:

npm install hexo-cli -g 

Installation hexo

hexo other commands :

$ hexo g

The complete command is: hexo generate is used to generate static files

$ hexo s

The complete command is: hexo server used to start the server, mainly for local preview

$ hexo d

The complete command is: hexo deploy for publishing to a local file on github

$ hexo n 

The full command is hexo new article for the New

3. Enter the Git Bash, enter:

hexo init   

Initialization warehouse
4. Input dependencies installed:

npm install 

After successfully enter:

hexo g 

with:

hexo s

5. Enter your browser to http: // localhost: 4000 / can view the local preview

Two .Hexo related configuration

1. Enable NexT theme

There are two main configuration file in Hexo in their names are _config.yml.
Among them, a site located in the root directory contains the main configuration Hexo itself; another is located in the theme directory, this configuration provided by the subject of the main options for configuring relevant to the subject.
For convenience of description, in the following description, the former known as the site configuration file, which is called the theme configuration file.

We open the site configuration file, find the theme field and change its value next.
After successfully configured, wait a little, then start again using git base hexo, enter hexo g and hexo s will be able to see the Next topic and successful use.

2.NexT configuration

Appearance settings
open theme configuration file, and then lift the Scheme in the # comment, choose their own themes.

Muse - 默认 Scheme,这是 NexT 最初的版本,黑白主调,大量留白
Mist - Muse 的紧凑版本,整洁有序的单栏外观
Pisces - 双栏 Scheme,小家碧玉似的清新

Note: You need to have a space after setting style

Language settings
to open the site configuration file, find the language, and then set the type of voice.
NexT currently supported languages as shown in the following table:
language code setting example

English	en	language: en
简体中文	zh-Hans	language: zh-Hans
Français	fr-FR	language: fr-FR
Português	pt	language: pt or language: pt-BR
繁體中文	zh-hk 或者 zh-tw	language: zh-hk
Русский язык	ru	language: ru
Deutsch	de	language: de
日本語	ja	language: ja
Indonesian	id	language: id
Korean	ko	language: ko

Menu Settings
to open theme configuration file, find the menu, and then select the main menu display.
NexT default menu item there (marked item expressed the need to manually create this page):
key value is set to display text (Simplified Chinese)

home	home: /	主页
archives	archives: /archives	归档页
categories	categories: /categories	分类页 
tags	tags: /tags	标签页 
about	about: /about	关于页面 
commonweal	commonweal: /404.html	公益 404

After setting, you need to set the appropriate text corresponding to the menu, which is the translation of the menu.
Found languages / {language} .yml, and edit the corresponding description on the list.
Such as: setting the language is language: zh-Hans, opened zh-Hans.yml.

Avatar is set
in the theme configuration file editing avatar avatar path input on the line.
images in hexo / public / images in.
Such as: avatar: /images/ljnoit.png

Baidu Statistics
Address: https://tongji.baidu.com/web/welcome/login
After logging (not registered), then the new website, enter the domain name on the line, then there will be a bunch of js code, copy hm.js behind that? statistics script string id, then paste it into the theme configuration file baidu_analytics on the line.

Social Links
edit the subject profile and increase social links and instructions on the line.
For example: https: //blog.csdn.net/Ljnoit

Label classification
under the site directory, open the git bash, enter hexo new page "categories" to create a classification.
Input: hexo new page "tags" hexo new page "about" and create a label on.
Create a play at the next site directory source folder will add a categories, tags, about the folder, which has a index.md file, change the description after opening for the Chinese, the Chinese are also displayed.
comments can be set to false, meaning open category page, comments plugin does not show.

Three .Hexo association github blog and upload local

1. Create a repository on github above

After a successful login github (not created first created), create a warehouse, warehouse youname.github.io youname name format for the user name. For example: ljnoit.github.io

After After successfully created, click on the warehouse, select the setting, and then drag GitHub Pages interface, then select Choose a theme, just choose a theme. Click again setting to GitHub Pages to can be found there is a path to access the path, you can access the repository interface set up.

2.Hexo association Github

This and the previous steps related to warehouse the same.

Set git identity information
in a directory hexo right git base input:

git config --global user.name "你的用户名"
git config --global user.email "你的邮箱"

Plus the address of the warehouse in the site configuration file, pay attention to add .git

3. Publish blog

First, a new blog post.
Such as: hexo new post "Hello GitHub"
will be in the \ source \ _posts will see Hello GitHub.md file.
To be published on the blog under the \ source_posts path. Blog recommended markdown editor whose names .md.

Before release, the first editor of the blog, to write description. Then enter:

hexo g //生成静态文件  
hexo s // 本地预览

Then enter: hexo d posted to github.
Enter the path youname.github.io can see the blog after success.

IV. Registering a domain name and bound to Github

Ali cloud first log in, search for domain names or domain names found in the console. After entering, first query the domain name you want to apply, if it means finding out it can be registered. There are many domain name registration extension, if so, recommend the .com.
After a successful application for a domain name, the domain name and Github binding, IP address, or Github is 192.30.252.153 192.30.252.154. So we resolved to fill the time, resolve this address. As Github is how to find our warehouse, the settings in CNAME.
Click [Add] resolved after entering the domain name resolution; in turn fill in the appropriate content.
"Record Type" Select A; "host record" fill WWW; "analytical line" Select Default;
"Recording" fill in the IP address provided github, 192.30.252.153 or 192.30.252.154;
"the TTL" default 10 minutes, they can separately settings can be;
and finally click [save].

After a successful domain name resolution, create a CNAME in your Github repository above, and then enter the address you apply for domain names. Then you enter your domain name can access the Github blog.

Published 21 original articles · won praise 30 · views 4285

Guess you like

Origin blog.csdn.net/Ljnoit/article/details/104043776