Hexo commands
Install Hexo, make sure you have node.js installed
npm install hexo-cli -g |
Create hexo folder (your site folder)
hexo init <folder-name> |
Once initialised, the site folder structure looks like:
. |
New post: If no layout is provided, Hexo will use the default_layout from _config.yml. If the title contains spaces, surround it with quotation marks. The new post file appears in /source/_posts.
$ hexo new [layout] <title> |
Start server: by default http://localhost:4000/
hexo server |
Clean cache file db.json
hexo clean |
Watch file changes in debug mode
hexo s --debug |
Generate static file
hexo generate |
Before deployment, in _config.yml file
deploy: |
Deploy the website
hexo deploy |
If ERROR shows like Deployer not found: github, it needs to change the deploy type to git.
npm install hexo-deployer-git --save |
Commands shortcut
hexo g == hexo generate |
Create draft and publish it
hexo new draft <title> |
Drafts are not displayed by default. You can add the --draft option when running Hexo or enable the render_drafts setting in _config.yml to render drafts.
Ref: Hexo getting started
Hexo themes
1. NexT
Install NexT theme
git clone https://github.com/iissnan/hexo-theme-next themes/next
Folow the setup instructions in /theme/next/_config.yml
2. Bootstrap
Another theme, Bootstrap, with good layout and available functions.
3. Pacman
A bueatiful theme, Pacman.
Create post TOC
It might be a different based on the theme, but the logic behind is similar. Taking the NexT theme for instance, in /theme/next/layout/_macro, find the file post.swig, which configures the post content display.
{% if post.toc %} |
There are two controls there, so in the post front-matter, one can add toc: true for display TOC and toc_num: true for showing list numbers.
For defaut display TOC, just change the if statement, e.g.,
{% if (post.toc == false) %} |
Then, you don’t have to set front-matter for each post.
Error: Module version mismatch
It seems there is a mismatch between one of:
- The hexo in node_modules/.bin
- The hexo in /usr/local/bin/hexo
- The globally installed hexo which may well have been the one from 2.
One solution is:
npm uninstall -g hexo-cli |