Agenda
The process of building a blog is divided into three steps:
Write: Configuring the writing and formatting of the content
Build: Generate publishable final content from the original content you write
Publish: Make the content to be published visible to readers
Users who post content based on blog platforms only need to pay attention to the writing part, but to build an independent personal blog, all three aspects need to be concerned. Fortunately, there are a number of tools that help us simplify the process: the rich Markup language simplifies writing; the powerful static site builder simplifies builds; and the friendly hosting platform simplifies publishing.
The birth of this blog also benefited from these tools:
Write: Using Markdown, built-in grammar support for a lot of hierarchies, lists, hyperlinks, code, etc.
Build: Use Hexo, a few commands to complete the build, preview, and release steps
Release: Hosting with GitHub Pages, convenient and free
Next, I will explain how to complete the entire blog building process based on these tools in the following order:
- Environmental preparation
- Use of Hexo and NexT themes
- Configuration and deployment of GitHub Pages
- Bind a custom domain name (optional)
- Hexo’s detailed configuration process
Environmental preparation
- Install Node.js
Official website download: https://nodejs.org/en/download/
- Install Hexo
1 | $ npm install -g hexo-cli |
Use of Hexo and NexT themes
Common Hexo commands
- Initialization directory:
1 | $ hexo init [folder] |
- New article:
1 | $ hexo new [layout] <title> |
or
1 | $ hexo n [layout] <title> |
- New draft:
1 | $ hexo new draft <title> |
- Publish the draft as a formal article:
1 | hexo publish <title> |
- Generate a static file:
1 | $ hexo generate |
or
1 | $ hexo g |
- Listen for file changes:
1 | $ hexo g --watch |
$ hexo g -w
1 |
|
$ hexo deploy
1 |
|
$ hexo d
1 |
|
$ hexo d -g
1 |
|
$ hexo server
1 |
|
$ hexo s
1 |
|
$ hexo s –debug
1 |
|
$ hexo s –draft
1 |
|
$ hexo clean
1 |
|
$ cd hexo
$ git clone https://github.com/theme-next/hexo-theme-next themes/next
1 |
|
theme: next
1 |
|
language: en
1 |
|
$ hexo c && hexo g && hexo s
1 |
|
$ ssh-keygen -t rsa -b 4096 -C “your_email@example.com“
1 |
|
$ npm install hexo-deployer-git –save
1 |
|
deploy:
type: git
repo: git@github.com:
branch: master
1 |
|
$ hexo d -g
1 |
|
[create/edit source/CNAME]
[end]
1 |
|
avatar:
1 |
|
$ hexo new page tags
1 |
|
Type: “tags”
Comments: false
1 |
|
menu:
tags: /tags
1 |
|
$ hexo new page categories
1 |
|
Type: “categories”
Comments: false
1 |
|
menu:
tags: /categories
1 |
|
$ hexo new page about
1 |
|
menu:
about: /about
1 |
|
Post meta display settings
post_meta:
updated_at: true
1 |
|
updated:
1 |
|
Available value:
normal | night | night eighties | night blue | night bright
https://github.com/chriskempson/tomorrow-theme
highlight_theme: normal
1 |
|
Declare license on posts
Creative Commons 4.0 International License.
http://creativecommons.org/
Available: by | by-nc | by-nc-nd | by-nc-sa | by-nd | by-sa |
creative_commons: by
post_copyright:
enable: true
license: CC BY 4.0
license_url: http://creativecommons.org/licenses/by/4.0/
1 |
|
Disqus
disqus:
enable: true
shortname:
count: true
1 |
|
Social links
social:
gitHub: https://github.com/your-user-name
twitter: https://twitter.com/your-user-name
weibo: http://weibo.com/your-user-name
Social Icons
social_icons:
enable: true
Icon Mappings
gitHub: github
twitter: twitter
weibo: weibo
1 |
|
reward_comment: Adhere to original technology sharing, your support will encourage me to continue to create!
wechatpay: /path/to/wechat-reward-image
alipay: /path/to/alipay-reward-image
1 |
|
since: 2019
1 |
|
$ npm install hexo-generator-searchdb –save
1 |
|
search:
path: search.xml
field: post
format: html
limit: 10000
1 |
|
Local search
local_search:
enable: true
1 |
|
$ npm install hexo-generator-sitemap –save
1 |
|
sitemap:
path: sitemap.xml
1 |
|
User-agent: *
Disallow: /CNAME
Disallow: /README
Allow: /
Allow: /about/
Allow: /archives/
Allow: /categories/
Allow: /tags/
Allow: /css/
Allow: /images/
Allow: /js/
Allow: /lib/
Sitemap:
1 |
|
$ npm install hexo-generator-feed –save
1 |
|
feed:
type: atom
path: atom.xml
limit: 20 # Maximum number of posts in the feed (Use 0 or false to show all posts)
hub:
content:
1 |
|
$ npm un hexo-renderer-marked –save
$ npm i hexo-renderer-markdown-it –save
1 |
|
Markdown-it config
Docs: https://github.com/celsomiranda/hexo-renderer-markdown-it/wiki
markdown:
render:
html: true
xhtmlOut: false
breaks: false
linkify: true
typographer: false
quotes: ‘“”‘’’
plugins:
- markdown-it-abbr
- markdown-it-footnote
- markdown-it-ins
- markdown-it-sub
- markdown-it-sup
anchors:
level: 2
collisionSuffix: ‘v’
permalink: false
permalinkClass: header-anchor
permalinkSymbol:`