Hexo
安装Hexo
MacBookPro:xidianzxm.github.io zhangxm$ npm install -g hexo-cli
/usr/local/bin/hexo -> /usr/local/lib/node_modules/hexo-cli/bin/hexo
> fsevents@1.2.9 install /usr/local/lib/node_modules/hexo-cli/node_modules/fsevents
> node install
node-pre-gyp WARN Using needle for node-pre-gyp https download
[fsevents] Success: "/usr/local/lib/node_modules/hexo-cli/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64/fse.node" is installed via remote
+ hexo-cli@2.0.0
added 257 packages from 457 contributors in 127.861s
╭───────────────────────────────────────────────────────────────╮
│
│ New minor version of npm available! 6.5.0 → 6.9.0
│ Changelog: https://github.com/npm/cli/releases/tag/v6.9.0
│ Run npm install -g npm to update!
│
╰───────────────────────────────────────────────────────────────╯
hexo init
MacBookPro:xidianzxm.github.io zhangxm$ pwd
/data/github/gitpages/xidianzxm.github.io
MacBookPro:xidianzxm.github.io zhangxm$ hexo init
INFO Cloning hexo-starter https://github.com/hexojs/hexo-starter.git
Cloning into '/data/github/gitpages/xidianzxm.github.io'...
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 74 (delta 2), reused 4 (delta 2), pack-reused 68
Unpacking objects: 100% (74/74), done.
Submodule 'themes/landscape' (https://github.com/hexojs/hexo-theme-landscape.git) registered for path 'themes/landscape'
Cloning into '/data/github/gitpages/xidianzxm.github.io/themes/landscape'...
remote: Enumerating objects: 1, done.
remote: Counting objects: 100% (1/1), done.
remote: Total 896 (delta 0), reused 0 (delta 0), pack-reused 895
Receiving objects: 100% (896/896), 2.55 MiB | 15.00 KiB/s, done.
Resolving deltas: 100% (479/479), done.
Submodule path 'themes/landscape': checked out '73a23c51f8487cfcd7c6deec96ccc7543960d350'
INFO Install dependencies
npm WARN deprecated core-js@1.2.7: core-js@<2.6.8 is no longer maintained. Please, upgrade to core-js@3 or at least to actual version of core-js@2.
⸨░░░░░░⸩ ⠴ extract:js-yaml: sill extract js-yaml@^3.6.1 extracted to /data/github/gitpages/xidianzxm.github.io/node_modules/.staging/js-yaml-485316ea (63681ms)
> fsevents@1.2.9 install /data/github/gitpages/xidianzxm.github.io/node_modules/fsevents
> node install
node-pre-gyp WARN Using needle for node-pre-gyp https download
[fsevents] Success: "/data/github/gitpages/xidianzxm.github.io/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64/fse.node" is installed via remote
npm notice created a lockfile as package-lock.json. You should commit this file.
added 488 packages from 528 contributors and audited 4697 packages in 152.136s
found 2 low severity vulnerabilities
run `npm audit fix` to fix them, or `npm audit` for details
INFO Start blogging with Hexo!
MacBookPro:xidianzxm.github.io zhangxm$ ls -alt
total 296
drwxr-xr-x 10 zhangxm staff 320 6 3 09:56 .
-rw-r--r-- 1 zhangxm staff 138442 6 3 09:56 package-lock.json
drwxr-xr-x 287 zhangxm staff 9184 6 3 09:56 node_modules
drwxr-xr-x 3 zhangxm staff 96 6 3 09:48 themes
drwxr-xr-x 3 zhangxm staff 96 6 3 09:48 source
drwxr-xr-x 5 zhangxm staff 160 6 3 09:48 scaffolds
-rw-r--r-- 1 zhangxm staff 443 6 3 09:48 package.json
-rw-r--r-- 1 zhangxm staff 1765 6 3 09:48 _config.yml
-rw-r--r-- 1 zhangxm staff 65 6 3 09:48 .gitignore
drwxr-xr-x 4 zhangxm staff 128 5 29 10:59 ..
MacBookPro:xidianzxm.github.io zhangxm$ npm install
audited 4697 packages in 3.7s
found 2 low severity vulnerabilities
run `npm audit fix` to fix them, or `npm audit` for details
hexo g(hexo generate)
MacBookPro:xidianzxm.github.io zhangxm$ hexo g
INFO Start processing
INFO Files loaded in 242 ms
INFO Generated: index.html
INFO Generated: archives/index.html
INFO Generated: fancybox/blank.gif
INFO Generated: fancybox/jquery.fancybox.css
INFO Generated: fancybox/fancybox_loading.gif
INFO Generated: fancybox/fancybox_overlay.png
INFO Generated: fancybox/fancybox_loading@2x.gif
INFO Generated: fancybox/fancybox_sprite@2x.png
INFO Generated: archives/2019/06/index.html
INFO Generated: archives/2019/index.html
INFO Generated: fancybox/fancybox_sprite.png
INFO Generated: js/script.js
INFO Generated: css/fonts/FontAwesome.otf
INFO Generated: fancybox/helpers/jquery.fancybox-buttons.css
INFO Generated: fancybox/jquery.fancybox.pack.js
INFO Generated: fancybox/helpers/jquery.fancybox-media.js
INFO Generated: fancybox/helpers/jquery.fancybox-buttons.js
INFO Generated: css/fonts/fontawesome-webfont.eot
INFO Generated: css/fonts/fontawesome-webfont.woff
INFO Generated: fancybox/helpers/jquery.fancybox-thumbs.css
INFO Generated: fancybox/helpers/fancybox_buttons.png
INFO Generated: css/style.css
INFO Generated: fancybox/helpers/jquery.fancybox-thumbs.js
INFO Generated: css/fonts/fontawesome-webfont.ttf
INFO Generated: css/fonts/fontawesome-webfont.svg
INFO Generated: 2019/06/03/hello-world/index.html
INFO Generated: fancybox/jquery.fancybox.js
INFO Generated: css/images/banner.jpg
INFO 28 files generated in 515 ms
hexo server
主题安装
MacBookPro:xidianzxm.github.io zhangxm$ git clone git://github.com/shenliyang/hexo-theme-snippet.git themes/hexo-theme-snippet
Cloning into 'themes/hexo-theme-snippet'...
fatal: read error: Operation timed out
MacBookPro:xidianzxm.github.io zhangxm$ git clone https://github.com/shenliyang/hexo-theme-snippet.git themes/hexo-theme-snippet
Cloning into 'themes/hexo-theme-snippet'...
remote: Enumerating objects: 42, done.
remote: Counting objects: 100% (42/42), done.
remote: Compressing objects: 100% (33/33), done.
remote: Total 1184 (delta 16), reused 24 (delta 9), pack-reused 1142
Receiving objects: 100% (1184/1184), 1.08 MiB | 39.00 KiB/s, done.
Resolving deltas: 100% (660/660), done.
MacBookPro:xidianzxm.github.io zhangxm$ pwd
/data/github/gitpages/xidianzxm.github.io
MacBookPro:xidianzxm.github.io zhangxm$ ls
_config.yml db.json node_modules package-lock.json package.json public scaffolds source themes
MacBookPro:xidianzxm.github.io zhangxm$ cd themes
MacBookPro:themes zhangxm$ ls
hexo-theme-snippet landscape
安装主题插件
因为 hexo-theme-snippet 使用了 ejs 模版引擎 、 Less CSS预编译语言以及在官方插件的基础上 进行功能的开发,以下为必装插件:
MacBookPro:themes zhangxm$ npm i hexo-renderer-ejs hexo-renderer-less hexo-deployer-git -S
npm WARN babel-eslint@10.0.1 requires a peer of eslint@>= 4.12.1 but none is installed. You must install peer dependencies yourself.
+ hexo-renderer-ejs@0.3.1
+ hexo-renderer-less@1.0.0
+ hexo-deployer-git@1.0.0
added 111 packages from 164 contributors, updated 1 package and audited 7027 packages in 28.276s
found 2 low severity vulnerabilities
run `npm audit fix` to fix them, or `npm audit` for details
部署主题
1)gulp打包构建,拷贝主题目录下package.json文件到Hexo根目录下,然后安装项目的开发依赖。
MacBookPro:themes zhangxm$ npm i
npm WARN babel-eslint@10.0.1 requires a peer of eslint@>= 4.12.1 but none is installed. You must install peer dependencies yourself.
up to date in 12.214s
MacBookPro:themes zhangxm$
2)在Hexo根目录下创建一个名为 gulpfile.js 的文件:
require('./themes/hexo-theme-snippet/gulpfile');
3)运行 gulp:
gulp 或者 gulp default //执行打包任务
4)清空hexo静态文件和缓存,并重新生成
hexo clean && hexo g //清空缓存并生成静态文件
5)本地预览,确没有问题再进行发布
hexo s -p 4000 或者 hexo s //启动本地服务默认
6) 当gulp执行完成,并提示 please execute: hexo d 时,可以进行发布
hexo d 或者 gulp deploy //部署发布
MacBookPro:source zhangxm$ pwd
/data/github/gitpages/xidianzxm.github.io/themes/hexo-theme-snippet/source
MacBookPro:source zhangxm$ ls
assets css favicon.ico fonts img js
MacBookPro:source zhangxm$ vi CNAME
oilyuncle.com
这里遇到点坑,一开始使用了git命令上传代码,CNAME删除后,“Settings”设置需要手工配置一下,只上传CNAME文件好像不生效