hexo+github builds personal blog

Preparation in windows environment

  1. Download and install node.js and install it, npm is installed by default
  2. Download and install git and Git Bash

Build hexo static blog locally

  1. Create a new folder, such as myBlog
  2. Go to the folder, right clickGit Bash Here
  3. Download and install hexo: npm install hexo-cli -g
    • image.png
  4. Generate a hexo template: hexo init blog (initialize the folder)
  5. Go to the blog folder: npm install
  6. Enter the blog folder: hexo server (visit the local localhost:4000 to see that the blog has been successfully built)
  • image.png

Associate blog with github

  1. Create a repository named xxx.github.io on Github, where xxx is your github username.
  2. Open the _config.yml configuration file in the blog folder of the local myBlog and set the type in it to git
  • image.png
  1. Go to the blog folder and run npm install hexo-deployer-git --save
  • image.png
  1. hexo generate
  2. hexo deploy
  3. Go to the repo corresponding to xxx.github.io and open the GitHub Pages function. If it is already open, just click the preview link. You can also open a browser and visit: https://qfstudy.github.io

edit blog

  1. hexo new blog title
  2. Edit the corresponding md file under \source_posts
  • image.png
  1. hexo generate
  2. hexo deploy
    then opens the blog and sees his newly edited blog

update article

  1. Execute in the blog directory: hexo new "My first post", a .md file will be generated in the source/_posts folder.
  2. Edit the file (following Markdown rules)
  3. Modify start field
  • title title of the article
  • date creation date (the date the file was created)
  • updated modification date (the modification date of the file)
  • comments Whether to enable comments true
  • tags tags
  • categories
  • name (filename) in permalink url
  1. Write the body content (MakeDown)
  2. hexo clean deletes local static files (Public directory), but it is optional.
  3. hexo g generates local static files (Public directory)
  4. hexo deploy pushes local static files to github (hexo d)

Note on uploading source code
(xxx.github.io) only saves your blog, and does not save the program code for generating the blog. You need to create an empty warehouse named blog-generator (you can name it freely) to save The program code for generating blog in myBlog.

  • image.png
  • image.png

hexo deployIn the future , the blog will be git add /git commit /git pushupdated after each session ; and then you have to check again 上传生成博客的程序代码, just in case.


change theme

  1. Enter Hexo's official website theme column
  2. github:https://github.com/hexojs/hexo/wiki/Themes
  3. Copy its SSH address or HTTPS address, assuming the address is [email protected] :iissnan/hexo-theme-next.git
  4. cd themes
  5. git clone [email protected]:iissnan/hexo-theme-next.git
  6. cd ..
  7. Change line 75 of _config.yml to theme: hexo-theme-next, save
  8. hexo generate
  9. hexo deploy
  10. Wait a minute, then refresh your blog page and you'll see a new look. If you don't like the theme, go back to step 1 and choose a new theme.

nextTheme configuration

  1. Change social links, modify in _config.yml of theme folder
    • image.png

Reference
https://github.com/limedroid/HexoLearning

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325124003&siteId=291194637