Use Hexo to quickly build a blog and deploy it to Github
This article aims to record the process of setting up a blog through Hexo and deploying it on Github. It will also help me learn and reference it quickly in the future. For more details or official documents, click the official Hexo document.
Prerequisites
Installing Hexo is very simple. Pre-installation required:
Install and configure Node. js v4.0.0 on Ubuntu 14.04/15.04
How to install Node. js in CentOS 7
Build a Node. js development environment in Ubuntu 14.04
Git server setup and Client installation
After the prerequisites are met, you can start to install Hexo.
Install Hexo
Open Git Bash and execute the command
1
|
$ npm install -g hexo-cli
|
Create a blog
After Hexo is installed, run the following commands respectively. Hexo automatically generates the required folder.
1 2 3
|
$ Hexo init <folder >## <folder> specifies the file address for you $ Cd <folder> $ Npm install
|
For example, if you want to build a blog under D: \ my_hexo, run the following commands:hexo init D:\my_hexo
,cd D:\my_hexo
,npm install
After executing the command, if there is no problem, we can execute the startup command to view our blog.
Local Preview
1 2 3
|
$ Hexo server # Start the service. The default port is 4000. $ Hexo server-p xxxx # Start the service through a custom Port $ Hexo clean # Clear cache. You can run this command when the page is abnormal.
|
Enter http: // 127.0.0.1: 4000/in the browser to access
Create Repository
- Log on to github and click "+" in the upper right corner to Create a new repository.
Create a new repository
- Copy the newly created https connection:
https://github.com/Admol/admol.github.io.git
- Open
_config.yml
- Set deploy information, such:
1 2 3 4
|
deploy: type: git repository: https://github.com/Admol/admol.github.io.git branch: master
|
Set SSH key
Check whether a key already exists
Execute commands separately
Then execute the commandls
Check that an existing key file exists. If a key exists, it is displayed.id_rsa.pub
Andid_dsa.pub
No key is displayed for these two files.
Add an SSH key
Run the following command (skip step 2 if the key already exists ):
1 2 3
|
$ Ssh-keygen-t rsa-C "your_email@mail.com"
# T specifies the key type. The default value is rsa, which can be omitted. -C: Set the comment text, such as email address or other text.
|
Then you will be promptedEnter Enter file in which to save the key (/c/Users/you/.ssh/id_rsa): [Press enter
Enter a file name to save the ssh key. The defaultid_rsa.pub
Andid_dsa.pub
After you press enter, you need to enter the password twice (this password is the password you need to enter when you push the file, rather than the github password)
After entering the password, the following information is displayed. The SSH key is successfully added.
Set SSH key on Github
Log on to github and clickSettings
And then clickSSH keys
On this page, you can manage all your ssh keys
Then clickAdd SSH key
Open the added key file in a text editorid_rsa.pub
, Copy all content in it
Return to the github page and paste the copied content to the text box corresponding to the key of the page. You can enter the title as needed.
Test whether the ssh key is successfully added.
On the command line, enter:
1
|
$ ssh -T git@github.com
|
There will be a warning code. Enter yes and press Enter. Then you will be asked to enter the password you just set. Then it will say to you:Hi, handsome guy... about?
Now the SSH key is set.
Deploy to Github
Open the command window and return to your hexo blog directory. Do not execute the following command:
1 2
|
hexo generate hexo deploy
|
After the command is executed, you can check whether the Code has been submitted to github, and enter admol. github. io in the browser to access it.
Create page
1
|
$ hexo new page 'pageName'
|
After executing the command, you can/source
The folder named after the page is added to the directory.
Display page
After opening the file, you canindex.md
Edit and open/themes/jacman
Directory_config.yml
File (the topic you are using ),
Add the newly added page:
1 2 3 4 5
|
Menu: Homepage :/ Statistics:/archives About:/about PageName:/pageName # the preceding pageName can be customized, and the following pageName must be the name of the newly added page.
|
Create an article
1
|
$ hexo new [layout] 'name'
|
[Layout] is optional. If this parameter is left blank, the default value is post./source
The folder name under the directory islayout
Name
Installation topic
1
|
$ git clone https://github.com/JamesPan/hexo-theme-icarus.git themes/icarus
|
Change subject
First download the topic, and then open_cinfig.yml
, ModifyTheme: name of the topic to be changed
Modify topic color
Open/themes/jacman
Directory_config.yml
File, modify:
1 2
|
Theme_color: Theme: 'color value'
|
Modify logo image
Open_config.yml
File, modify:
1 2 3 4
|
Imglogo: Enable: false # Show logo Src: img/logo.gif # logo image address Favicon: img/qq. ico # icon in the upper left corner of the page
|
Hexo Version Upgrade
GitHub Tutorials:
Create a personal technical blog via GitHub
GitHub tutorials
Git tag management details
Git branch management
Git remote repository details
Git local Repository (Repository) Details
Git server setup and Client installation
Git Overview
Share practical GitHub tutorials
GitHub details: click here
GitHub: click here
This article permanently updates the link address: