安装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 installnode-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.0added 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.ioMacBookPro:xidianzxm.github.io zhangxm$ hexo initINFO Cloning hexo-starter https://github.com/hexojs/hexo-starter.gitCloning 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 68Unpacking 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 dependenciesnpm 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 installnode-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 remotenpm 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.136sfound 2 low severity vulnerabilities run `npm audit fix` to fix them, or `npm audit` for detailsINFO Start blogging with Hexo!MacBookPro:xidianzxm.github.io zhangxm$ ls -alttotal 296drwxr-xr-x 10 zhangxm staff 320 6 3 09:56 .-rw-r--r-- 1 zhangxm staff 138442 6 3 09:56 package-lock.jsondrwxr-xr-x 287 zhangxm staff 9184 6 3 09:56 node_modulesdrwxr-xr-x 3 zhangxm staff 96 6 3 09:48 themesdrwxr-xr-x 3 zhangxm staff 96 6 3 09:48 sourcedrwxr-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 .gitignoredrwxr-xr-x 4 zhangxm staff 128 5 29 10:59 ..MacBookPro:xidianzxm.github.io zhangxm$ npm installaudited 4697 packages in 3.7sfound 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 gINFO Start processingINFO Files loaded in 242 msINFO Generated: index.htmlINFO Generated: archives/index.htmlINFO Generated: fancybox/blank.gifINFO Generated: fancybox/jquery.fancybox.cssINFO Generated: fancybox/fancybox_loading.gifINFO Generated: fancybox/fancybox_overlay.pngINFO Generated: fancybox/fancybox_loading@2x.gifINFO Generated: fancybox/fancybox_sprite@2x.pngINFO Generated: archives/2019/06/index.htmlINFO Generated: archives/2019/index.htmlINFO Generated: fancybox/fancybox_sprite.pngINFO Generated: js/script.jsINFO Generated: css/fonts/FontAwesome.otfINFO Generated: fancybox/helpers/jquery.fancybox-buttons.cssINFO Generated: fancybox/jquery.fancybox.pack.jsINFO Generated: fancybox/helpers/jquery.fancybox-media.jsINFO Generated: fancybox/helpers/jquery.fancybox-buttons.jsINFO Generated: css/fonts/fontawesome-webfont.eotINFO Generated: css/fonts/fontawesome-webfont.woffINFO Generated: fancybox/helpers/jquery.fancybox-thumbs.cssINFO Generated: fancybox/helpers/fancybox_buttons.pngINFO Generated: css/style.cssINFO Generated: fancybox/helpers/jquery.fancybox-thumbs.jsINFO Generated: css/fonts/fontawesome-webfont.ttfINFO Generated: css/fonts/fontawesome-webfont.svgINFO Generated: 2019/06/03/hello-world/index.htmlINFO Generated: fancybox/jquery.fancybox.jsINFO Generated: css/images/banner.jpgINFO 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-snippetCloning into 'themes/hexo-theme-snippet'...fatal: read error: Operation timed outMacBookPro:xidianzxm.github.io zhangxm$ git clone https://github.com/shenliyang/hexo-theme-snippet.git themes/hexo-theme-snippetCloning 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 1142Receiving 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.ioMacBookPro:xidianzxm.github.io zhangxm$ ls_config.yml db.json node_modules package-lock.json package.json public scaffolds source themesMacBookPro:xidianzxm.github.io zhangxm$ cd themesMacBookPro:themes zhangxm$ lshexo-theme-snippet landscape
安装主题插件
因为 hexo-theme-snippet 使用了 ejs 模版引擎 、 Less CSS预编译语言以及在官方插件的基础上 进行功能的开发,以下为必装插件:
MacBookPro:themes zhangxm$ npm i hexo-renderer-ejs hexo-renderer-less hexo-deployer-git -Snpm 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.0added 111 packages from 164 contributors, updated 1 package and audited 7027 packages in 28.276sfound 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 inpm 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.214sMacBookPro: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/sourceMacBookPro:source zhangxm$ lsassets css favicon.ico fonts img jsMacBookPro:source zhangxm$ vi CNAMEoilyuncle.com
这里遇到点坑,一开始使用了git命令上传代码,CNAME删除后,“Settings”设置需要手工配置一下,只上传CNAME文件好像不生效