hexo combined with git to build blog Foundation

Posted by tomboy78 on Wed, 04 Dec 2019 11:40:45 +0100

background

How to own your own blog without spending money (server, domain name)? gitpage+hexo, realize your wish

Preparation

  1. Install git client by yourself
  2. Self registration of git account
  3. Install npm and node.js by yourself

Operation steps

Building database

Create a new one named( Your user name.github.io )For example, if your user name of GitHub is username, you will create a new warehouse of username.github.io
The access address is http://username.github.io

Configure SSH key

cd ~/. ssh #Check the existing ssh key on this machine
//Tip: No such file or directory indicates that you are using git for the first time.
ssh-keygen -t rsa -C "mailing address"
//Press enter to generate a file in the user directory, find the. ssh\id_rsa.pub file, open and copy the contents
//Open your github homepage and enter personal settings - > SSH and GPG keys - > New SSH key:
//Paste the content you just copied to the key. The title is free and saved.
//Testing effect
ssh -T git@github.com # Note that the email address does not need to be changed
//Are you sure you want to continue connecting (yes/no)? Enter yes
//Hi XXXXXX is a success
//Continue to configure personal information
git config --global user.name "xxx"// Your github user name, non nickname
git config --global user.email  "xxx@qq.com"// Fill in your github registration email

hexo installation configuration and use

//install
npm install -g hexo 
//Initialization
//Create a new folder named hexo (random name), for example, my folder is D:\hexo
cd /d/hexo/
hexo init
//Generate html file according to. md in public
hexo g 
//Start local service
hexo s
//Change the default theme (hexo supports N multi themes, please check the corresponding documents for details, yilia and next are good)
git clone https://github.com/litten/hexo-theme-yilia.git themes/yilia

Change the site configuration file _config.yml to enable yilia topics

//Change landscape to yilia
theme: yilia
//Executive liquidation
hexo clean
//Regenerate
hexo g

Change git configuration in the site configuration file

//For hexo 3, do not exclude the change of higher version
deploy:
  type: git
  repository: git@github.com:username/username.github.io.git
  branch: master

Install hexo deployer GIT. Otherwise, an error is reported. Deployer not found: github

npm install hexo-deployer-git --save

Submit to git

hexo d

Common hexo commands

hexo new "postName" #New article
hexo new page "pageName" #New page
hexo generate #Generate static page to public directory
hexo server #Turn on preview access port (default port 4000, 'ctrl + c' turn off server)
hexo deploy #Deploy to GitHub
hexo help  # view help
hexo version  #View version of Hexo
//Abbreviation
hexo n == hexo new
hexo g == hexo generate
hexo s == hexo server
hexo d == hexo deploy
//combination
hexo s -g #Generate and preview locally
hexo d -g #Generate and upload

About writing articles

sublime + markdown plug-in or atom or vscode is recommended
Easy to debug md documents
Learn about mardown grammar by yourself (very simple)

Topics: git github ssh npm