Build a blog Based on Hexo and Github and build hexogithub
Build your own blog.
Preparations
Make sure that you have downloaded and installed node and npm on your computer. To check whether the installation is successful, you only need to enter the following two commands in the command line for windows.
Install hexo
Check whether hexo is successfully installed.
Note: An error may be reported. You can try it.
1 |
Npm install hexo -- no-optional |
Go to the local project directory and initialize hexo
Install the dependency package in package. json in npm
Generate blog files
Start a local blog
Enterhttp://localhost:4000
You can access the hexo blog of the default topic.
View hexo help
Modify the global configuration file
For_congig.yml
Modify the configuration.
Website
Parameters |
Description |
title |
Website title |
subtitle |
Website subtitle |
description |
Website description |
author |
Your name |
language |
Language used by the website |
timezone |
Website time zone. Hexo uses the time zone of your computer by default. Time zone list. For example:America/New_York ,Japan , AndUTC . |
URL
Parameters |
Description |
Default Value |
url |
URL |
|
root |
Website root directory |
|
permalink |
Permanent Link format of the article |
:year/:month/:day/:title/ |
permalink_default |
Default value of each part of the permanent link |
Directory
Parameters |
Description |
Default Value |
source_dir |
Resource folder, which is used to store content. |
source |
public_dir |
Public folder, which is used to store generated site files. |
public |
tag_dir |
Tag folder |
tags |
archive_dir |
Archive folder |
archives |
category_dir |
CATEGORY folder |
categories |
code_dir |
Include code folder |
'Downloads/code |
i18n_dir |
International (i18n) folder |
:lang |
skip_render |
Skip the rendering of the specified file. You can use the glob expression to match the path. |
Article
Parameters |
Description |
Default Value |
new_post_name |
File Name of the new article |
: Title. md |
default_layout |
Preset Layout |
Post |
auto_spacing |
Add spaces between Chinese and English |
False |
titlecase |
Convert title to title case |
False |
external_link |
Open link in new tag |
True |
filename_case |
Convert the file name to (1) lower case or (2) upper case |
0 |
render_drafts |
Show draft |
False |
post_asset_folder |
Start the Asset folder |
False |
relative_link |
Change the link to the relative address of the root directory. |
False |
future |
Show future articles |
True |
highlight |
Code block settings |
CATEGORY & tag
Parameters |
Description |
Default Value |
default_category |
Default category |
uncategorized |
category_map |
CATEGORY alias |
|
tag_map |
Label alias |
Date/time format
Hexo uses Moment. js to parse and display the time.
Parameters |
Description |
Default Value |
date_format |
Date Format |
MMM D YYYY |
time_format |
Time Format |
H:mm:ss |
Paging
Parameters |
Description |
Default Value |
per_page |
Number of articles displayed per page (0 = the paging function is disabled) |
10 |
pagination_dir |
Paging directory |
page |
Extension
Parameters |
Description |
theme |
The name of the current topic. The value isfalse When topic is disabled |
deploy |
Deployment settings |
Configure github to create a repository
Generate Test page
Go to the newly created repository, click settings in the upper-right corner, click launch automatic page generator on the jump page, click continue to layouts on the jump page, select the topic, and generate the page. after about 15 minutes, visithttps://syd1992.github.io
To display the test generation page.
Create an ssh keys
1 |
$ Ssh-keygen-t rsa-C "847909475@qq.com" |
After you enter the command, you will be prompted to enter the ssh keys storage location. Generally, you do not need to change it. Press enter directly. Then, you will be prompted to enter the password and then be sure to enter the password again. This password will be used later,Remember!
1 |
$ Cat ~ /. Ssh/id_rsa.pub |
Add ssh keys to the github Repository
Test connection
Run the command, enter the command, ask yes/no, enter yes, and prompt to enter the password, enter the password set when generating the ssh keys
The following message is displayed, indicating that the operation is successful.
1 |
Hi, user name/user name. github. io! You 've successfully authenticated, but GitHub does notprovide shell access. |
Configure and release the _ config. yml file in the root directory
1 |
$ Npm install hexo-deployer-git -- save |
Accesshttps://syd192.github.io.git
You can see your hard work !!
Switch topic
The default topic is landscape. If you do not like it, visit here to get more topics. I chose TKL as the topic. The specific switching method is as follows:
1 |
$ Git clone https://github.com/SuperKieran/TKL.git theme/TKL |
Then,hexo g
, Againhexo d
.
Note: Fill in the image url. the img folder should be placed in the source file directory, and the url can be directly written as/img/image .png.
Write a blog
Then,hexo g
, Againhexo d
.
Finally, let's look at the results chart and continue to cheer up ~~~~
Reference