win10 build hexo blog and deploy to github

The main steps are as follows:

  1. Download node.js
    • hexo blog is a static blog based on node.js, so node.js must be installed. It is worth mentioning that when installing node.js, npm will be installed by default. The full name of npm is Node Package Manager, which is used to manage (install or uninstall) related packages of node.js, which greatly simplifies our operation of packages, so we will use npm to install hexo later.
    • Node.js is installed all the way to next, the default option is sufficient. After the installation is complete, open cmd, enter node -v, if the version number is displayed, the installation is successful
  2. Use npm to install hexo
    • Because of the existence of npm, our installation of hexo is very simple. Just enter the npm i -g hexo-clicommand to complete the installation of hexo. However, due to domestic network speed limitations, PlanB can be used if the installation is unsuccessful.
    • PlanB: Use Taobao's domestic mirror source curve to save the country, install cnpm first, and the cmd command is npm i -g cnpm --registry=https://registry.npm.taobao.org. Then use cnpm to install hexo, the command is similar to npm cnpm -i -g hexo-cli(it is recommended to install the official recommended hexo-cli instead of hexo)
    • Can be used hexo -vto determine whether the installation was successful
  3. Create a blog with hexo
    • First create a folder to store future blogs. Then cdenter the folder and use the hexo initcommand to initialize. If everything goes well, you will be prompted: the
      Insert picture description here
      directory structure should be like this:
      Insert picture description here
      and enter the hexo sstart service, after completion, the browser visits http: // localhost: 4000, you can see the home page generated by hexo. The four commands on the homepage will be used frequently in the subsequent blog creation, and the meanings they represent are as follows:

        hexo new "My New Post"  // 创建博客,可简写为 hexo n
        hexo server   // 启动本地服务,可简写为 hexo s
        hexo generate   //生成静态文件,可简写为 hexo g
        hexo depoly    //部署到远端,可简写为 hexo d
      
    • Next, write a blog in actual combat, first hexo ncreate a blog with commands (here a markdown file is created): the
      Insert picture description here
      created blog is stored at the address / source / _posts /
      and then you can use the vim command or other ways to edit the blog (I use the Typora editor here, mainly to see at the results)
      after editing, use hexo cleanto clear db.json cache (not necessarily, if the site shows abnormalities, try using), then hexo ggenerate static file, and finally start the service hexo s, enter the URL access, you can see just write blog friends .
      Insert picture description here

  4. Push to github
    • First of all, we need to have a github account, and configure the SSH key , and then we can create a new warehouse . Note that the warehouse name must be username.github.io, this warehouse name is the url address of the future visit blog.
    • Next, we need to push the local blog to github, so we need to configure the "_config.yml" file after init. This file is very important. After that, we need to use this configuration file to modify the theme and add pictures to the blog. We find the Deployment and modify it to the following figure: repo is our warehouse address. Note that there is a space after the colon.
      Insert picture description here
    • Also you need to download a plug-in deployment: cnpm install hexo-deployer-git --save. After installation, it hexo dcan be deployed to github as long as it is used . In the middle, we may need to enter the github username and password.
    • If all goes well, enter the warehouse address in the browser username.github.ioto see our blog deployed on github.
      Insert picture description here
tips:

  In this process, it is inevitable that it will fail due to factors such as network speed. If there is a problem, just delete the newly created blog folder and try again, because all our operations are performed in this folder, so it is a big deal.
  Of course, if you are successful, you can also try to change your favorite blog theme. I recommend themes with more stars on github , such as next and yilia . I use the next theme myself, which is very concise and atmospheric.
  Let's choose a good-looking theme and let's blog together ~

Published 2 original articles · received 2 · views 259

Guess you like

Origin blog.csdn.net/weixin_44386939/article/details/105623302