Configure Node.js environment
1. Download the Node.js installation file: nodejs China official website
Choose the corresponding installation file according to your Windows version. as the picture shows:
Just keep the default settings, all the way to Next, the installation will soon be over.
Then we check if the required components are installed, press Win and R at the same time to open the running window:
Enter cmd in the newly opened window and hit enter to open the command line interface. (The following will directly use the open command line to indicate the above operation, remember~)
In the command line interface that opens, enter
node -v
npm -v
If the result is as shown in the figure below, it means the installation is correct and you can proceed to the next step. If it is not correct, you need to go back and check your own installation process.
Install Git
GIt official website download addressDomestic
download station
Like Node.js, most settings just need to be left at default.
After the installation is complete, turn off and reopen the command line just now, otherwise there is no git command.
Similarly, let's check if Git is installed correctly, open the cmd command line and enter:
git --version
If the result is as shown in the figure below, it means the installation is correct and you can proceed to the next step. If it is not correct, you need to go back and check your own installation process.
Registration and configuration of coding account
Most of the domestic websites are in Chinese, so I won’t say anything about registration, just enter Coding and scroll the keyboard ==
Create Project (Coding Pages)
After registration, go to the homepage, click on the project, and click + to create a project.
Check whether the Pages service is turned on: click Project -> Code -> Pages Service, if it is not turned on, click Open
Configure SSH and Git
Then after we have a free server, we need to bind a personal computer to contact them, that is, after SSH is bound with Git, we don’t need to enter an account and password every time we deploy a project
Generate SSH Key
Open git command window
Enter the following command
ssh-keygen -t rsa -C [email protected]
Change [email protected] to your email, and then you will be asked to confirm the path and enter the password. We just use the default one and press Enter. If successful, a .ssh folder will be generated under ~/,
execute cd .ssh
it,
execute it to cat id_rsa.pub
view the content, copy the key inside, the rude point is Ctrl+a and then Ctrl+c
Add SSH Key
You need to verify your email address to add it.
Coding, log in to the homepage, place the mouse on the avatar, personal account-personal settings
Personal account —> SSH public key —> enter the key and click add
After verifying the password, you can add it successfully.
Verification success
Verify coding
ssh -T [email protected]
If it is the first time, you will be prompted whether to continue, enter yes and you will see:
You’ve successfully authenticated, but coding does not provide shell
access
This means that the coding has been successfully connected! The next thing we need to do is to upload the local warehouse to the coding. Before that, we need to set the username and email, because coding will record them every commit.
git config --global user.name your_name
git config --global user.email [email protected]
Replace your_name and [email protected] above with yours.
Install Hexo
I think in the right place to create a folder here with me G:\hexo
as an example to explain, first create Hexo folder directory in the E drive, and cmd command-line window into the directory
Enter in the command line:
npm install hexo-cli -g
Then you will see:
You may see a WARN, but don't worry, it will not affect your normal use.
Let's see if Hexo is already installed. Enter in the CMD command line :
hexo -v
If you see the text as shown, it means that the installation has been successful.
Related configuration of hexo
Keep typing
hexo init
Then type
npm install
Hexo will automatically download some files to the directory just created.
Experience Hexo for the first time to continue the operation, also in the command line, enter
hexo g
Then type
hexo s
Then it will prompt:
INFO Hexo is running at http://localhost :4000/. Press Ctrl+C to stop.
Open http://localhost :4000/ in the browser, and an initial blog is greeted.
To stop the keyboard after previewing, press Ctrl + C to stop the local preview
So far, the local configuration of Hexo has all ended.
Connect Hexo and coding page
Configure Deployment Before that, install the Git deployment plugin. Press ctrl+c to stop the hexo preview, and then enter the following command.
npm install hexo-deployer-git --save
The above command must be entered after entering the hexo installation path . That E:\hexo
is, because it has been in this directory before, so there is no need to switch paths.
Open the blog folder below, you will see a file like this:
This file means to make some settings for your blog, such as your user name, etc. Remember this file is especially important! , You have to configure here in the future, let’s open it with notepad++, this is your website information
If you don’t understand English, check the dictionary. Note: put a space after the name, otherwise you will make a mistake! ! !
Then slip to the bottom and fill in your git address. This step is very important. You can write it according to me. Also, don't forget the space!
Then click the file to save or directly press Ctrl+S.
post article
To create a new blog, enter the hexo file directory on the command line or git bash, and then execute the following command:
hexo new post "article title"
The following is what I executed after entering git bash in the hexo directory
24222@DESKTOP-R7NOJG5 MINGW64 /E/hexo
$ hexo new post 这是第一篇文章
INFO Created: E:\hexo\source\_posts\这是第一篇文章.md
At this time, in the directory of your computer: hexosource _posts will see the md file
, open it with the MarDown editor and you can edit the post. After the article is edited, run the generation and deployment commands:
hexo g // 生成
hexo d // 部署
Of course, you can also execute the following commands, which are equivalent to the effects of the above two commands
hexo g -d #在部署前先生成
After successful deployment, visit your address, https://yourname.coding.me will be able to see the generated article.
Reprinted and modified: hexo+next tutorial (1)-简书