As a programmer, it’s not uncommon to have some strange problem to solve or learn some new skill because the business needs it. The vehicle to organize and share these experiences is a personal blog. (Just for the satisfaction)
Step 1: Environment setup
1. Install Node.js
Installing Node comes with NPM, which can be used to install plugins for blogs, and the Node environment is now an essential part of front-end development.
Go to the Node.js website, select the installation package, and mindlessly install next. (LTS: Long-term stable version; CURRENT version:
After the installation is complete, run the following command to check whether the installation is successful
Node -v 2. NPM -vCopy the code
If the version number appears, the installation is successful
2. Install Git
Windows:
Go to the official website to download and install
Mac:
1. Install Git from Homebrew
- If homebrew is not installed, install it first
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Copy the code
- Install git
brew install git
Copy the code
2. Install using Xcode
Install Xcode directly from the AppStore. Xcode is integrated with Git, but it is not installed by default. You need to run Xcode, go to “Xcode” -> “Preferences”, and go to “Downloads” in the popup window. Select Command Line Tools and click Install to complete the installation.
Step 2: Install Hexo
Once git and Node are installed, we can initialize our Hexo project (git won’t be used until we deploy the blog)
1. Install hexo-CLI globally
npm install hexo-cli -g
Copy the code
After the installation is complete, continue to use hexo -V to check the version and verify that the installation is successful
2. Initialize the blog project
Go to your desktop and use the command hexo init Blog(Blog is the name of the file, take whatever you want). After initialization, you get a Blog folder, CD goes into this folder, and use NPM Install to install dependencies. Once installed, you can use hexo Server or NPM Run Server to run your blog project
When you see the information in the image above, follow the instructions in the last line and open your browser to http://localhost:4000 to see the generated blog. The default is as follows
The current default is definitely not what we want, so we can then modify the configuration of the blog to suit our needs.
If you don’t like the default theme, take a look at the theme provided on the official website, or go to Github and search for hexo theme and use the hexo theme keyword. (I recommend hexo-theme-matery as my blog theme. I think it’s pretty good.)
Step 3: Deploy the blog
Hexo provides a plug-in called Hexo-deployer-git that deploys Hexo projects to Github in one click. (This step is only the simplest way to deploy the blog, if you can not meet the requirements can search for other methods, here will not post links to other methods, sorry)
1. Create a Github account if you don’t have one
If github is not available, you can search the host configuration online, or method 1, method 2
The above two methods are also my own online find the release time is relatively new article, not guaranteed to be able to use, but almost all methods are around the configuration of host implementation. Note: After configuring the host, you should close the browser and open it again, or swipe the browser and try to enter Github again
2. New warehouse
Github Pages is used to deploy blogs to the repository. So we need to build a warehouse for our blog first.
After the Github account is newly created and logged in, a new repository will appear on the left side of the page. The repository name is < your GitHub username >.github. IO. You will be able to use this name to visit your blog site in the future.
3. Generate SSH
I won’t leave this step out, but it’s important to push your code to Github successfully.
First open a command line tool and type the following command:
Git config --global user.email -- git config --global user.email -- git config --global user -t rsa -c 'Your email'Copy the code
If you want to confirm something, press Y. If you want to confirm something, press enter. When you are told that SSH has been generated successfully, a.ssh folder will be generated on your computer, with the following contents
“Id_rsa. pub” is what we want. Copy the contents of this file to Github (click on the github profile picture, select Settings, go to SSH and GPG keys, and click New SSH key to add SSH).
Give yourself a name for the title and paste the contents of the id_RSA.pub that you just copied.
Finally, go to the command line and type SSH -t [email protected] to verify that you can access Github.
When this line of text appears, it means success! Host = host; host = host; host = host; host = host; host = host 1111.111.11.1 github, then type SSH -t [email protected] again to see that the prompt is missing. It doesn’t seem to matter how many of those lines are used.)
4. Deploy Hexo to Github
First go to the blog project and type the following command to install dependencies
npm install hexo-deployer-git --save
Copy the code
Then go to the configuration file _config.yml in the project root directory and swipe it to the bottom and change the Deployment configuration in it as follows
deploy:
type: git
repo: <repository url> #https://bitbucket.org/JohnSmith/johnsmith.bitbucket.io
branch: [branch]
message: [message]
Copy the code
parameter | describe |
---|---|
repo | Git code base address |
branch | The name of the branch |
message | Customize submission information |
About branch: Generally speaking, a new code base will have only one branch, master, so branch as master is ok.
About repO: If you don’t know the address of the codebase, the easiest way is to go to Github, find the codebase you want to deploy, and click code to get the address of the codebase, as in
When this step is ready to deploy, type the following command
Hexo generate/hexo g // deploy 3. Hexo deploy/hexo dCopy the code
When “Deploy Done” is displayed, the deployment is successful. Remember the name of the repository you created earlier? XXX. Making. IO. You will be able to access your blog via this address in a few minutes.
I found a 443 error in the deployment process, baidu found a solution, the deployment configuration of the REPO address from HTTPS to SSH
Now that you’ve built your own blog, it’s time to write articles/personalize your website. Finish scattering flowers.
Reference:
- Dye ink small white blog build article.
- Hexo – theme – matery.