Click "Blue WeChat Name" under the title to quickly follow
Many people have their own blogs, so they use the Hexo static blog framework and Github to build one. The detailed tutorial will be shared with you below.
Hexo is a fast, concise and efficient blogging framework. It can render hundreds of pages in seconds. Hexo supports all the features of Github Flavored Markdown, and even integrates most plugins of Octopress. It also has powerful plugins. system.
1. Git download
download link:
https://git-for-windows.github.io/
I believe I don’t need to say more about git. If you don’t know git yet, let’s learn it first with github.
2. Node.js download
download link:
https://nodejs.org/en/
Just install it by default.
3. Configure Github
1. Register a github account, create a library, and the library name must be yourname.github.io, yourname is your github username.
2. Configure in _config.yml
4. Install Hexo
1. Use the npm command to install. Right-click anywhere and select Git Bash
Then enter the command:
npm install -g hexo
If the command not found is displayed, delete the directory you just installed and execute the above command again.
5. Initialize Hexo
1. Create a folder named Hexo on a certain disk (for example, create a folder named Hexo on D disk)
2. In the Hexo folder , run Git Bash and enter the command: hexo init (must be run in the folder you just created)
To install dependencies enter this command: npm install
3.生成静态页面,输入此命令:
hexo g
本地启动
启动本地服务,输入此命令:
hexo s
输入完成后,打开浏览器输入http://localhost:4000
如果成功的话会显示如下页面:
但是也有可能报如下错误:
fatal: unable to access 'https://github.com/*/*.github.io.git/': Failed to connect to github.com port 443: Timed out FATAL Something's wrong. Maybe you can find the solution here: http://hexo.io/docs/troubleshooting.html Error: fatal: unable to access 'https://github.com/*/*.github.io.git/': Failed to connect to github.com port 443: Timed out
解决方法为:
将hexo配置文件——config.yml中repo里更改为
https://用户名:密码@新建github库的地.git然后就可以了。
如果是第一次,然后执行命令:
npm install hexo-deployer-git --save
然后再执行
hexo d
然后再浏览器中输入http://yourname.github.io/就行了,yourname是你的github的账户名,至此博客就基本搭建完成了。
附加:如果出现ERROR Deployer not found: git 或者 ERROR Deployer not found: github
Workaround: npm install hexo-deployer-git --save
4. Deployment steps
The steps of each deployment in the future can be carried out according to the following three steps.
hexo clean
hexo g
hexo d
5. Common commands
shorthand
hexo n "My Blog" == hexo new "My Blog" #New article hexo p == hexo publish hexo g == hexo generate#Generate hexo s == hexo server #Start service preview hexo d == hexo deploy# deploy
server
The shorthand hexo server #Hexo will monitor file changes and update them automatically, you don't need to restart the server. hexo server -s #Static mode hexo server -p 5000 #Change port hexo server -i 192.168.1.1 #Custom IP hexo clean #Clear the cached webpage under normal circumstances, this command can be ignored hexo g #Generate static webpage hexo d #Start deploy
This article is just a simple construction, and I will continue to update a series of articles about blog configuration.
Recommended reading
[Collection] Summary of 32 technical blog posts