current position:Home>【github pages】: build a github pages under windows, update the blog in real time

【github pages】: build a github pages under windows, update the blog in real time

2022-11-24 22:37:52Jack_Kuo

I made it once before, lost it, and tried it again.

1. Preparation

  • Install git: https://git-scm.com/download/win
  • Install node: https://nodejs.org/en/
  • Install cnpm: npm install -g cnpm --registry==https://registry.npm.taobao.org
  • Install hexo: cnpm install -g hexo-cli
  • Generate .ssh key: ssh-keygen -t rsa -C "your github login email"
  • Copy the public password to github: Copy the contents of C:\Users\your username\.ssh\id_rsa.pub to github homepage, enter personal settings -> SSHand GPG keys -> New SSH key
  • Configure user and email: git config --global user.name "your Github username" and git config --global user.email "[email protected]"

2. Blog building process

  • Create warehouse, CrazyMilk.github.io;
  • Create two branches: master and hexo;
  • Set hexo as the default branch (because we only need to manually manage the Hexo website files on this branch);
  • Use git clone [email protected]:CrazyMilk/CrazyMilk.github.io.git to copy the warehouse;
  • In the local CrazyMilk.github.io folder, execute npm install hexo, hexo init, npm install and npm install hexo-deployer-git sequentially through Git bash (at this time - the current branch should be displayed as hexo);
  • Modify the deploy parameter in _config.yml, the branch should be master;
  • Execute git add ., git commit -m “…”, git push origin hexo in sequence to submit website-related files;
  • Execute hexo generate -d to generate the website and deploy it to GitHub.

In this way, the CrazyMilk.github.io warehouse on GitHub has two branches, a hexo branch is used to store the original files of the website, and a master branch is used to store the generated static web pages.Perfect ( •̀ ω •́ )y!

3. Blogging with Typora

3.1 Introduction to Typora

Typora is a lightweight and compact Markdown editor that supports instant rendering technology, which is the most significant difference from other Markdown editors.Instant rendering allows you to write Markdown as smoothly as writing a Word document, unlike other editors that have a formula bar and a display bar.

Advantages:

  • Simple and beautiful

  • Live preview

  • Extended Syntax

  • Cross-platform

3.2 Install Typora

Address: typora-setup-x64(1).exe

3.3 Blogging

1. In the D:\hexo directory, by entering the command: hexo new "article title" will be in the /source folderGenerate the .md file of the corresponding article, and then you can open this file through Typora to write the article and save it

2. After you finish writing the article, enter the following commands to generate the article:

  • hexo clean : Delete the public folder, i.e. delete old blog posts

  • hexo g : Generate a public folder, that is, generate a new blog post related html file

  • hexo s : local view

  • hexo d : Push blog to master on github

3. In addition, the following command is required to push the deployment resources of this update to hexo

  • git add .
  • git commit -m "update"
  • git push -u hexo hexo:hexo

3.4 Insert pictures into Hexo blog

When only a few images are used in the Hexo project, the images can be placed in the source/images folder and accessed through markdown syntax.

![You can write a description about the picture](/images/image.jpg)

Images can be accessed both within the homepage content and within the body of the article.

copyright notice
author[Jack_Kuo],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/328/202211242234419167.html

Random recommended