janblank499

janblank499

Hexo Blog Setup Tutorial I

After reinstalling the system, I found that I had forgotten all the knowledge of environment configuration. I'm writing a tutorial for my future self, and if it can help others, that would be even better.
This article refers heavily to Argvchs' Hexo Blog Setup Tutorial Part I. In fact, the title of this article is also derived from it.
I also referred to Kaitaku's Building a Hexo Blog from Scratch

0. Introduction#

Hexo is a fast, simple, and powerful blog framework. Hexo uses Markdown (or other rendering engines) to parse articles and generates static web pages with beautiful themes in seconds.
Here are some tutorials related to Markdown:

1. Local Installation of Git & Node.js & Hexo CLI#

  • Git
    https://git-scm.com/downloads
    After installation, right-click on the desktop or any folder to open the git terminal by clicking on "git bash here" and check with the git --version command.
    (Unless otherwise specified, all commands below are executed in the git terminal)
  • Node.js
    https://nodejs.org
    Generally, choose the LTS (Long Term Support) version and confirm the installation.
    When using the official Node.js installer, make sure to check the "Add to PATH" option (it is checked by default).
    After completion, check with the node -v and npm -v commands.
  • Hexo CLI
    Enter the command npm install hexo-cli -g
    And check with hexo -v
  • Install Plugins
    Deployment plugin: pnpm add hexo-deployer-git. After installation, you can use hexo -d to deploy the blog to GitHub.
  • Configure GitHub SSH Key
    Generate an SSH key with the command ssh-keygen -t rsa -C "[email protected]" (Note: enter your registered GitHub email address)
    Open the local SSH key file and copy it with the command notepad %USERPROFILE%\.ssh\id_rsa.pub (You can also open it from a text editor)
    Click on the avatar in the upper right corner of the GitHub page to go to the Settings page, click on the left side SSH and GPG keys, click on New SSH key in the upper right corner, paste the SSH key into the key field, leave the Title blank, and click Add SSH key to add the key.
    Bind Git and GitHub with the following command in the local terminal:
    git config --global user.name "<user>"
    git config --global user.email "<email>"
    
  • Configure Branch
    Create a new repository on GitHub as the repository for your blog. The repository name should be <user>.github.io, for example, if my username is janblank499, the repository name would be janblank499.github.io, and make sure the repository is public.
    Open the branch settings page: Branch Settings. The first input field is the default branch (old version: master, new version: main).
    Open the _config.yml file in your blog's root directory and set the parameters. Note that branch: should be consistent with the default branch.
    deploy:
      type: 'git'
      repository: **
      branch: **
    

With the above, all the settings before building the blog are completed. The next step is to generate the blog locally and deploy it.
Next: Hexo Blog Setup Tutorial Part II

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.