安装主题
1. 下载主题
在hexo
官网下载自己喜欢的主题,放置到themes
目录下,然后在_config.yml
文件内修改theme
属性为你的主题文件名,重启服务可以查看效果。
这里下载的是icarus
A simple, delicate, and modern theme
responsivemodernlightcardone_columnmulti_column
文件夹的目录如下:
.
├── _config.yml
├── package.json
├── scaffolds
├── source
| ├── _drafts
| └── _posts
└── themes
2.修改_config.yml文件
## Themes: https://hexo.io/themes/
# theme: landscape
theme: icarus
3.开启服务
liangyuji@liangyujideMBP blog % hexo server
INFO Validating config
INFO =======================================
██╗ ██████╗ █████╗ ██████╗ ██╗ ██╗███████╗
██║██╔════╝██╔══██╗██╔══██╗██║ ██║██╔════╝
██║██║ ███████║██████╔╝██║ ██║███████╗
██║██║ ██╔══██║██╔══██╗██║ ██║╚════██║
██║╚██████╗██║ ██║██║ ██║╚██████╔╝███████║
╚═╝ ╚═════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚══════╝
=============================================
INFO === Checking package dependencies ===
ERROR Package bulma-stylus is not installed.
ERROR Package hexo-renderer-inferno is not installed.
ERROR Package hexo-component-inferno is not installed.
ERROR Package inferno is not installed.
ERROR Package inferno-create-element is not installed.
ERROR Please install the missing dependencies your Hexo site root directory:
ERROR npm install --save [email protected] hexo-renderer-inferno@^0.1.3 hexo-component-inferno@^0.10.1 inferno@^7.3.3 inferno-create-element@^7.3.3
ERROR or:
ERROR yarn add [email protected] hexo-renderer-inferno@^0.1.3 hexo-component-inferno@^0.10.1 inferno@^7.3.3 inferno-create-element@^7.3.3
问题:icarus主题所需的依赖没有安装.
ERROR npm install --save [email protected] hexo-renderer-inferno@^0.1.3 hexo-component-inferno@^0.10.1 inferno@^7.3.3 inferno-create-element@^7.3.3
安装依赖,按上面提示安装
liangyuji@liangyujideMBP blog % npm install --save [email protected] hexo-renderer-inferno@^0.1.3 hexo-component-inferno@^0.10.1 inferno@^7.3.3 inferno-create-element@^7.3.3
> [email protected] postinstall /Users/liangyuji/Desktop/workspace/blog/node_modules/inferno
> opencollective-postinstall
Thank you for using inferno!
If you rely on this package, please consider supporting our open collective:
> https://opencollective.com/inferno/donate
+ [email protected]
+ [email protected]
+ [email protected]
+ [email protected]
+ [email protected]
added 185 packages from 89 contributors in 10.925s
24 packages are looking for funding
run `npm fund` for details
问题:_config.icarus.yml ,files is found,不用理会,重启后会自动生成
INFO === Checking package dependencies ===
INFO === Checking theme configurations ===
WARN None of the following configuration files is found:
WARN - /Users/liangyuji/Desktop/workspace/blog/_config.icarus.yml
WARN - /Users/liangyuji/Desktop/workspace/blog/themes/icarus/_config.yml
INFO Generating theme configuration file...
INFO /Users/liangyuji/Desktop/workspace/blog/_config.icarus.yml created successfully.
INFO To skip configuration generation, use "--icarus-dont-generate-config".
INFO === Registering Hexo extensions ===
INFO Start processing
问题: 页面加载很慢,是因为加载大量的国外资源
找到_config.icarus.yml,在最后的providers,修改:全部修改为loli
providers:
# Name or URL template of the JavaScript and/or stylesheet CDN provider
cdn: loli
# Name or URL template of the webfont CDN provider
fontcdn: loli
# Name or URL of the fontawesome icon font CDN provider
iconcdn: loli
找到themes/icarus(主题)/layout/common/head.jsx
注释掉:
default: fontcdn(‘Ubuntu:wght@400;600&family=Source+Code+Pro’, ‘css2’),
const fontCssUrl = {
// default: fontcdn('Ubuntu:wght@400;600&family=Source+Code+Pro', 'css2'),
cyberpunk: fontcdn('Oxanium:wght@300;400;600&family=Roboto+Mono', 'css2')
};