Hexo series (1) Building a Hexo blog

Hexo is a fast, concise and efficient blogging framework. Hexo uses Markdown (or other rendering engine) to parse articles and in seconds, generates static web pages with beautiful themes.

Attach the official Chinese document: Hexo official document

basic environment

To build a blog framework based on Hexo, you need the following environment (if not, check the installation tutorial of the official documentation by yourself):

  • Git

  • Node.js

  • GitHub account

Install Hexo

In the directory folder you like, there is a "Git Bash Here" option in the right-click menu, click to open the terminal and enter the following command

$ npm install -g hexo

After installation, enter

$ hexo init

Install dependencies:

$ npm install

Now you can enter the common commands of hexo to see the initial appearance of hexo

$ hexo g //generate 生成静态文件的命令
$ hexo s //server 启动并运行在本地服务器的命令

Then visit localhost:4000 to see Hexo successfully.
But now this blog is only running on your local, you need to use GitHub to deploy it on the network.

Deploy Hexo to Github - configuration file

Create a repository (i.e. project) in Github
build warehouse

(Note: The repository name must be your Github account name.github.io)

Then use Notopad++ (a very powerful, powerful and powerful text editing software) to open the _config.yml file in the root directory of hexo (it is best to back it up first)
and pull it to the bottom of the file, find the deploy node, and configure the deployment of your hexo blog website.

deploy:
  type: git
  repo:
      github: [email protected]:TonyLoveCoding/TonyLoveCoding.github.io.git,master

Please note the following:

  • When configuring, replace the TonyLoveCoding of this code with your own Github account name.

  • All colons in Hexo's configuration files must be followed by a space.

  • For the new version of Hexo, the indentation of each line in the configuration file is the identification of the node level, do not enter the tab symbol arbitrarily. For example, the - sign in front of depoly means that it has two child nodes type and repo, and repo has child nodes github and so on.
    configure

Deploying Hexo to Github - Configuring SSH

GitBash input command:

ls -al ~/.ssh

If you are an old Github user, there should be an SSH file, if not, continue

ssh-keygen -t rsa -C "[email protected]"

Remember to change to your Github's bound mailbox, and just press Enter when you encounter it. Then the following command:

ssh-agent -s
ssh-add ~/.ssh/id_rsa

If it goes wrong, try

eval `ssh-agent -s`
ssh-add

After success, you should be able to see id_rsa.pub in the C:/Users/your username/.ssh directory. Open it
SSH
with Notepad++ and copy all the contents inside. Go to Setting in GitHub and perform the following operations:
Fill in SSH
This completes the configuration of SSH, then test SSH

ssh -T [email protected]

Yes if there is an input. Now let's start deploying to GitHub. Install the hexo-deployer-git module first

npm install hexo-deployer-git --save

Then start deploying:

hexo g //generate 生成静态文件
hexo d //deploy 部署到配置文件中指定的地点

You can now access your blog at: your GitHub name.github.io

post article

hexo new "test_new_artcle"

Then there is the test_new_artcle.md file under \hexo\source_posts.
Since Hexo recommends Markdown for writing articles, we'd better download Markdownpad to facilitate writing articles.
markdownpad
On the left is our markdown writing area, and on the right is the real-time effect display area.
Regarding the syntax of markdown, I will write an article to introduce it later when I have time.
After writing your article, the old command:

hexo g  //编译生成文件
hexo s  //本地预览
hexo d  //同步文件到Github

That's it, you've finished writing articles on your blog for others to watch.

other

If you are tired of Hexo's default theme, you can go to the official theme page to find the theme you like, and then learn how to improve the UI and style effects, and you can create a true independent blog.

Of course, hexo doesn't stop there, remember to go to the official documentation to see more, there are many features waiting for you to discover.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324792795&siteId=291194637
Recommended