How does Hexo migrate to a new computer

This is the 18th day of my participation in the August Genwen Challenge.More challenges in August

Preface:

This is what happened once. I was negligent in backing up the data, so I lost the source of Hexo and had to rebuild the blog… Since I recently bought a MAC, IN order to migrate my blog to a new computer, I wrote a special article on how to migrate Hexo to a new computer.

The article on how to back up was written a long time ago, everything is tears…

Note.youdao.com/ynoteshare1…

Problems encountered

After moving to the new computer, it was found that the previous Hexo could not be used locally, so it was time to search for a solution

The old computer has been formatted and all source code data has been wiped, so I have to rebuild the blog

Things that need to be done

  1. Re-blog
  2. GIT Backup
  3. Periodically synchronize

practice

(Source and other files can be restored)

1. Set the secret key on git

SSH -keygen -t rsa -c “[email protected]

Then press Enter three times to generate the secret key

$ssh-keygen -t rsa -c “[email protected]”(your email address) Generating public/private RSA key pair. Enter file in which to save the key (/c/Users/xxxxxx/.ssh/id_rsa):

Under C:\Users\xxxx. SSH, you can see the secret key, id_rsa is the private key, do not leak, id_rsa.pub is the public key, we need to copy the contents of the public key

Go to git Hub and select Setting

Select SSH and GPG keys

Select the New SSH key

Fill in the title, copy the content in rSA_public, click Add, and enter the password to complete the key creation

2. Install the node

After git setup is complete, the next step is to prepare the environment for restoration. First of all, we need to go to the official website of Node. js to download the corresponding installation package, such as the following Chinese website:

nodejs.cn/download/

After entering the website, we need to download the corresponding installation package for installation. The LTS version is recommended here.

Once you’re done installing Node, don’t worry. First check to see if you’re actually installed. Use the following three commands to check if you have the environment.

node -v
​
npm -v
​
Git --version
Copy the code

3. Install hexo

New versions of Node include tools such as NPM, so there is no need to install them manually, and it is not recommended to install them using CNPM. Instead, use NPM directly.

npm install -g hexo-cli
Copy the code

The problem here is that since the MAC says no permissions, sudo is added to the command above, as follows:

sudo npm install -g hexo-cli
Copy the code

Permission sudoy (” permission “) if the MAC does not have permission to run the “node” command

Once installed, the following commands can be used to install hexo, again due to personal MAC use:

sudo npm install -g hexo
Copy the code

4. Pull the backup from Git to local

This step is to use Git Clone to pull a local copy of the previous article, as shown in this example.

git clone -b hexo https://xxxx/hexo
Copy the code

After this step is complete, there is only a local infrastructure for hexo, at this point, the hexo command cannot be executed, we still need to run NPM install to install node and hexo dependencies into the current directory, generating the corresponding node_moudules file.

npm install
Copy the code

After the installation is complete, we can play happily.

5. Hexo basic operations

It’s been a while since hexo used it, but there are only a few operations left for Hexo to perform, such as the following command to place the notes written by the note-taking software into the hexo generated file and add a <! The — more — > TAB completes the output of a single note, which is then deployed and automatically pushed to github and Gitee branches.

// Create a new theme hexo cl hexo g hexo dCopy the code

Personally, I like to use the following article template:

Title: {{title}} subtitle: 'This person is lazy, don't want to write subtitle' Author: Lazytime url_suffix: random date: {{date}} tags: - No categories: - Unclassified Keywords: Enter keywords (multiple keywords are separated by commas) Description: Enter description copyright: trueCopy the code

conclusion

Backup and restore is very fast, except for the node permissions stuck in the middle, basically in less than half an hour you can quickly set up a local hexo blog, very convenient.

Write in the last

Suggest every one have a blog of my own, because you don’t know which day your cloud notes operators cause problems, like the previous drops, also pay attention to backup more at ordinary times, do not like me, silly not to format the hard disk results all forgot to put the content of the blog kao out to rewrite…