本博客使用hexo+github搭建
- 申请一个github账号
- 安装了node.js、npm,并了解相关基础知识
- 安装了git for windows(或者其它git客户端)
新建一个名为你的用户名.github.io的仓库
ssh-keygen -t rsa -C "邮件地址"
$ git config --global user.name "username"// 你的github用户名,非昵称
$ git config --global user.email "[email protected]"// 填写你的github注册邮箱
$ npm install -g hexo
$ cd /d/Code/hexo/
$ hexo init
$ cd /d/Code/hexo/
$ git clone https://github.com/litten/hexo-theme-yilia.git themes/yilia
$ hexo g # 生成
$ hexo s # 启动服务
$ hexo d #提交
格式
https://raw.githubusercontent.com/{user}/{repo}/master/{folderpath}/{filename}
示例
https://raw.githubusercontent.com/PGzxc/CDN/master/blog-Interview/flutter-01-widget-life.webp
格式
https://cdn.jsdelivr.net/gh/{user}/{repo}/{folderpath}/{filename}
示例
https://cdn.jsdelivr.net/gh/PGzxc/CDN/blog-hmos/harmonyos-lesson1-xmind.png
示例
https://jsd.onmicrosoft.cn/gh/PGzxc/CDN/blog-hmos/harmonyos-lesson1-xmind.png
npm install hexo-offline --save
// hexo-offline v2 配置示例
module.exports = {
// 是否启用插件
enable: true,
// 缓存的文件匹配规则(支持 glob)
caches: [
'**/*.css',
'**/*.js',
'**/*.woff2',
'**/*.woff',
'**/*.ttf',
'**/*.svg',
'**/*.png',
'**/*.jpg',
'**/*.gif',
'**/*.webp',
'**/*.ico'
],
// 忽略缓存的文件
ignores: [
'**/drafts/**'
],
// Workbox 配置(生成的 Service Worker 逻辑)
workbox: {
globPatterns: ['**/*.{js,css,html,png,jpg,jpeg,svg,woff2}'],
maximumFileSizeToCacheInBytes: 5 * 1024 * 1024 // 5MB
},
// 额外要缓存的外部资源(可选)
external: [
'/lib/fontawesome/css/all.min.css',
'/lib/animate/animate.min.css',
'/lib/gitalk/gitalk.css',
'/lib/gitalk/gitalk.min.js'
]
}