工具 · Settle Down in Hexo
2021-12-28 16:53:06 # 工具(Tools)

记录一些Hexo维护相关的命令。

更换主题

Step 0: 在本地博客目录下打开 Git Bash。

Step 1: Clone Theme from Github:

1
git clone https://github.com/zchengsite/hexo-theme-oranges.git themes/oranges

Step 2: 编辑博客目录下的 _config.yml:

1
theme: oranges

写作和发布

官方文档

写作

  • 新文章:hexo new post <title>
  • 新草稿:hexo new draft <title>。草稿不会显示在博客里。
  • 发布草稿:hexo publish draft <title>。将草稿转成文章 (从 _draft/ 移动到 _post/)。

发布

  • 预览 (start) :hexo s, 之后访问localhost:4000。可以实时看到变化。
  • 生成 (generate):hexo g
  • 部署 (deploy):hexo d,之后访问博客地址即可。
  • 清除缓存 (clean):hexo clean,注意 generate 和 deploy 只会更新 .yml 设置和文章。因此在更改 css 文件后,需要在 generate 之前使用该命令清除缓存。

代码高亮配色

多行代码

theme/{current_theme}/source/css/highlight.css中更改配色。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
@decorator(param=1)
def f(x):
""" Syntax Highlighting Demo
@param x Parameter"""
s = ("Test", 2+3, {'a': 'b'}, x) # Comment
print s[0].lower()

class Foo:
def __init__(self):
byte_string = 'newline:\n also newline:\x0a'
text_string = u"Cyrillic Я is \u042f. Oops: \u042g"
self.makeSense(whatever=1)

def makeSense(self, whatever):
self.sense = whatever
if True:
pass

x = len('abc')
print(f.__doc__)

多标签文章

使用以下格式给文章添加多个标签:

1
2
3
4
5
6
title: Settle Down in Hexo
date: 2021-12-28 16:53:06
tags:
- 第一个标签
- 第二个标签
- 第三个标签