hexo + github pages to build personal blog (a)

Since it is desirable to gradually learn to configure personal blog, had been set up several before, have long since abandoned, study and documentation purposes are not reached, here re-start recording. First alert themselves, and second, as a record for easy reference.

The main steps:

1.github personal code repository configuration
git user.name configuration settings and configuration information user.email

git config --global user.name "github用户名"
git config --global user.email "github注册邮箱"

Generate ssh keys file

ssh-keygen -t rsa -C "github注册邮箱"

Enter here three straight, the default password is not set, find the file in the rescue .ssh folder id_rsa.pub keys C drive user directory, copy the contents to github_setting_keys page, create new ssh key

any title, copy the contents to key in. Click to add ssh key. In git bash can be detected github public setting was successful. Entry

ssh [email protected]

Displays the following information is successful

$ ssh [email protected]
PTY allocation request failed on channel 0
Hi lonely-island! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.

The reason here is set GitHub key reason is to complete the encryption by asymmetric public and private key encryption, public key placed on GitHub, private key is placed in its own computer. GitHub code is required each time the legitimate users push, push so every time you need to enter the account password to verify whether the user is a legitimate user push, eliminating the need to enter a password each time step, using a ssh, when you push, git it are your private key matches with GitHub above paired public key is, if you think you are matching the legitimate user is allowed to push. This ensures that every time the push is correct legal.

2. Install node

-V check node input node installation

3. Install hexo

Execute the following command in a fixed folder

#使用npm命令安装hexo
npm install -g hexo-cli
#完成后,初始化博客
hexo init blog
#以上命令执行的目录都是刚才指定文件夹里, 为了预览,可以使用这三条命令
hexo new test_my_site #新建一篇博客文章
hexo g #生成网页
hexo s #在本地预览
#打开localhost:4000查看
#常用的hexo命令
npm install hexo -g #安装hexo
npm update hexo -g #升级hexo
hexo init #初始化博客

3. Push website
_config.yml configuration file

  • There is a site configuration file under the root directory blog
  • There is a theme under the themes directory configuration file
    modified to the site profile
deploy:
type: git
repo: 这里填入你之前在GitHub上创建仓库的完整路径,记得加上 .git
branch: master参考如下:

This step is to give hexo d command to do this configuration, so the configuration blog hexo know where here is on github repository, and finally install git deployment of plug-in, the command:

npm install hexo-deployer-git --save

Then enter the three commands

hexo clean
hexo g
hexo d

Third is to deploy website deploy command, after the completion of open the browser, you can access the user name .github.io

After only need to write articles

hexo new "文章标题"

Then find a new generation of md file in ~ \ \ next blog source_posts can be edited at the beginning of the document attributes can be freely set
such an example

---
title: hexo新建文章
copyright: true
permalink: 1
top: 0
date: 2020-01-30 18:52:01
tags:
- hexo
- 博客
categories: web
password:
---

Preview locally before deploying it

hexo clean && hexo g && hexo s

In localhost: 4000 can be viewed, to finalize the correct use:

hexo d

It can be deployed on github pages access

A small configuration
you want to display only the first page article thumbnail, you can (_config.yml under the themes directory) in the theme configuration file changes, find auto_excerpt

# Automatically Excerpt. Not recommend.
# Please use <!-- more --> in the post to control excerpt accurately.
auto_excerpt:
  enable: true #是否启用自动摘要,截取50字
  length: 50

Select enable, it will be below this effect, length specified only shows how many characters from scratch. Or you can use into the article you want to capture position.
Thumbnails

Guess you like

Origin www.cnblogs.com/lonelyisland/p/12243519.html