1000字范文,内容丰富有趣,学习的好帮手!
1000字范文 > 从零开始的hexo与next主题配置github.io博客(入门篇)

从零开始的hexo与next主题配置github.io博客(入门篇)

时间:2021-05-07 18:05:24

相关推荐

从零开始的hexo与next主题配置github.io博客(入门篇)

新建GitHub仓库名为<username>.github.io。安装Node.js及Git。安装hexo:

npm install -g hexo-cli

切换到要保存hexo博客的目录<blog>,执行

hexo init

或直接执行

hexo init <folder>cd <folder>

然后执行

npm install

安装主题,以Next为例:切换到博客文件夹下后执行

git clone /theme-next/hexo-theme-next themes/next

编辑<blog>/_config.yml,填写title、subtitle、description、keywords、author、language。将url填写为http://<username>.github.io。如果之前使用的是旧版hexo需要参考Hexo版本升级和Next主题升级之坑更新后在time_format后添加update_option: 'mtime'。将theme改为next。添加plugin:

plugin:- hexo-generator-feedfeed:type: atompath: atom.xmllimit: 20search:path: search.xmlfield: postformat: htmllimit: 10000

添加Deployment配置:

deploy:type: gitrepository: /<username>/<username>.github.io.gitbranch: master

编辑<blog>/themes/next。更改scheme: Pisces。启用Dark Mode:将darkmode设置为true。启用commonweal等目录,将相应句子前的注释井号删掉。修改social配置,其中Google一栏plus.google已停用。links: Title:可添加其他地址。follow_me配置会在每篇文章末尾添加一个图标指向各个网站的链接,没必要。calendar配置将calendar_id改为Google邮箱,api_key需要在Google API Console,新建项目,然后在“API和服务”一栏下的“信息中心”一栏的页面中选择“ENABLE APIS AND SERVISES"如图:

搜索API和服务:

搜索Google Calendar:

点击Google Calendar API后点击“启用”,然后“创建凭据”:

点击“选择”选择Google Calendar API,然后点击“API密钥”创建。

github_banner配置中将enable设置为true,permalink设置为/<username>。将pjax设置为true。新建博文:执行

hexo new CSDN-1

会显示

INFO Created: D:\Documents\Programming\Aykablog\source\_posts\CSDN-1.md

其中标准命令为

hexo new [layout] <title>

[layout]可选项默认为post。执行

hexo generate

hexo g

显示

INFO Start processingINFO Files loaded in 370 msINFO Deleted: images/arrow-right-32x32-next.pngINFO Deleted: images/arrow-right-16x16-next.pngINFO Deleted: images/arrow-right.epsINFO Deleted: images/arrow-right.pngINFO Deleted: lib/font-awesome/HELP-US-OUT.txtINFO Deleted: lib/font-awesome/css/font-awesome.css.mapINFO Deleted: images/arrow-right.svgINFO Deleted: images/quote-l.svgINFO Deleted: images/quote-r.svgINFO Deleted: lib/font-awesome/bower.jsonINFO Deleted: lib/font-awesome/fonts/fontawesome-webfont.woffINFO Deleted: lib/font-awesome/fonts/fontawesome-webfont.woff2INFO Deleted: lib/font-awesome/css/font-awesome.cssINFO Deleted: lib/font-awesome/css/font-awesome.min.cssINFO Deleted: lib/font-awesome/fonts/fontawesome-webfont.eotINFO Deleted: images/arrow-right.icoINFO Deleted: images/41254968094E73320D03EFF9B33277C03C1168186.jpgINFO Generated: content.jsonINFO Generated: board/index.htmlINFO Generated: about/index.htmlINFO Generated: tags/index.htmlINFO Generated: categories/index.htmlINFO Generated: archives/index.htmlINFO Generated: archives//index.htmlINFO Generated: archives//03/index.htmlINFO Generated: tags/tutorial/index.htmlINFO Generated: /03/18/hello-world/index.htmlINFO Generated: /03/19/paper/index.htmlINFO Generated: index.htmlINFO Generated: js/algolia-search.jsINFO Generated: js/schemes/muse.jsINFO Generated: js/next-boot.jsINFO Generated: js/bookmark.jsINFO Generated: js/local-search.jsINFO Generated: css/main.cssINFO Generated: js/schemes/pisces.jsINFO Generated: js/utils.jsINFO Generated: lib/pjax/index.d.tsINFO Generated: lib/font-awesome/webfonts/fa-regular-400.woff2INFO Generated: lib/pjax/LICENSEINFO Generated: lib/pjax/lib/abort-request.jsINFO Generated: lib/pjax/example/example.jsINFO Generated: lib/pjax/lib/execute-scripts.jsINFO Generated: lib/pjax/package.jsonINFO Generated: lib/pjax/lib/is-supported.jsINFO Generated: lib/font-awesome/css/all.min.cssINFO Generated: lib/pjax/index.jsINFO Generated: lib/pjax/lib/foreach-selectors.jsINFO Generated: lib/pjax/lib/foreach-els.jsINFO Generated: lib/pjax/CHANGELOG.htmlINFO Generated: lib/pjax/lib/parse-options.jsINFO Generated: lib/pjax/lib/eval-script.jsINFO Generated: lib/pjax/example/page2.htmlINFO Generated: lib/pjax/lib/send-request.jsINFO Generated: lib/pjax/example/page3.htmlINFO Generated: lib/pjax/example/forms.htmlINFO Generated: lib/pjax/pjax.jsINFO Generated: lib/font-awesome/webfonts/fa-brands-400.woff2INFO Generated: lib/pjax/example/index.htmlINFO Generated: lib/pjax/README.htmlINFO Generated: lib/font-awesome/webfonts/fa-solid-900.woff2INFO Generated: lib/pjax/pjax.min.jsINFO Generated: lib/pjax/tests/setup.jsINFO Generated: lib/pjax/lib/switches-selectors.jsINFO Generated: lib/pjax/lib/uniqueid.jsINFO Generated: lib/pjax/lib/events/trigger.jsINFO Generated: lib/pjax/lib/switches.jsINFO Generated: lib/pjax/tests/test.tsINFO Generated: lib/pjax/lib/events/on.jsINFO Generated: lib/pjax/lib/proto/parse-element.jsINFO Generated: lib/pjax/lib/events/off.jsINFO Generated: lib/pjax/lib/proto/log.jsINFO Generated: lib/pjax/lib/proto/attach-form.jsINFO Generated: lib/pjax/lib/util/extend.jsINFO Generated: lib/pjax/lib/proto/attach-link.jsINFO Generated: lib/pjax/lib/proto/handle-response.jsINFO Generated: lib/pjax/lib/util/contains.jsINFO Generated: lib/pjax/lib/util/clone.jsINFO Generated: lib/pjax/lib/util/update-query-string.jsINFO Generated: lib/pjax/lib/util/noop.jsINFO Generated: lib/pjax/tests/lib/proto/attach-form.jsINFO Generated: lib/pjax/tests/lib/util/clone.jsINFO Generated: lib/pjax/tests/lib/eval-scripts.jsINFO Generated: lib/pjax/tests/lib/abort-request.jsINFO Generated: lib/pjax/tests/lib/is-supported.jsINFO Generated: lib/pjax/tests/lib/execute-scripts.jsINFO Generated: lib/pjax/tests/lib/foreach-els.jsINFO Generated: lib/pjax/tests/lib/foreach-selectors.jsINFO Generated: lib/pjax/tests/lib/parse-options.jsINFO Generated: lib/pjax/tests/lib/events.jsINFO Generated: lib/pjax/tests/lib/switches.jsINFO Generated: lib/pjax/tests/lib/util/contains.jsINFO Generated: lib/pjax/tests/lib/switch-selectors.jsINFO Generated: lib/pjax/tests/lib/uniqueid.jsINFO Generated: lib/pjax/tests/lib/send-request.jsINFO Generated: lib/pjax/tests/lib/util/noop.jsINFO Generated: lib/pjax/tests/lib/util/extend.jsINFO Generated: lib/pjax/tests/lib/proto/attach-link.jsINFO Generated: lib/pjax/tests/lib/proto/parse-element.jsINFO Generated: lib/pjax/tests/lib/util/update-query-string.jsINFO Generated: lib/pjax/tests/lib/proto/handle-response.jsINFO 84 files generated in 932 ms

执行

hexo server

hexo s

显示

INFO Start processingINFO Hexo is running at http://localhost:4000 . Press Ctrl+C to stop.

打开浏览器打开该网址即可预览。

如果没有更新,则需要执行

hexo clean

后重新生成并启动服务器。

执行

npm install hexo-deployer-git --save

注意此处必须为--save选项,全局安装无效报错:

INFO Validating configERROR Deployer not found: git

执行

hexo deploy

hexo d

将博客部署到GitHub上:

INFO Validating configINFO Deploying: gitINFO Setting up Git deployment...Initialized empty Git repository in D:/Documents/Programming/HexoBlog/.deploy_git/.git/[master (root-commit) 9cfa1ad] First commit1 file changed, 0 insertions(+), 0 deletions(-)create mode 100644 placeholderINFO Clearing .deploy_git folder...INFO Copying files from public folder...INFO Copying files from extend dirs...warning: LF will be replaced by CRLF in /07/27/CSDN-1/index.html.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in /03/19/paper/index.html.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in /09/27/CSDN-2/index.html.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in /09/28/hello-world/index.html.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in about/index.html.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in archives//07/index.html.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in archives//index.html.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in archives//03/index.html.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in archives//09/index.html.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in archives//index.html.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in archives/index.html.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in board/index.html.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in categories/CSDN/index.html.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in categories/index.html.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in css/main.css.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in index.html.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in js/algolia-search.js.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in js/bookmark.js.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in js/local-search.js.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in js/motion.js.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in js/next-boot.js.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in js/schemes/muse.js.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in js/schemes/pisces.js.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in js/utils.js.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in lib/anime.min.js.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in lib/font-awesome/css/all.min.css.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in lib/velocity/velocity.min.js.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in lib/velocity/velocity.ui.min.js.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in tags/Adobe/index.html.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in tags/Adobe安装错误/index.html.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in tags/Visual-Studio-Installer-Error/index.html.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in tags/index.html.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in tags/tutorial/index.html.The file will have its original line endings in your working directory[master 1d6cbde] Site updated: -09-28 00:53:3750 files changed, 15669 insertions(+)create mode 100644 /07/27/CSDN-1/index.htmlcreate mode 100644 /03/19/paper/index.htmlcreate mode 100644 /09/27/CSDN-2/index.htmlcreate mode 100644 /09/28/hello-world/index.htmlcreate mode 100644 about/index.htmlcreate mode 100644 archives//07/index.htmlcreate mode 100644 archives//index.htmlcreate mode 100644 archives//03/index.htmlcreate mode 100644 archives//09/index.htmlcreate mode 100644 archives//index.htmlcreate mode 100644 archives/index.htmlcreate mode 100644 board/index.htmlcreate mode 100644 categories/CSDN/index.htmlcreate mode 100644 categories/index.htmlcreate mode 100644 css/main.csscreate mode 100644 images/algolia_logo.svgcreate mode 100644 images/apple-touch-icon-next.pngcreate mode 100644 images/avatar.gifcreate mode 100644 images/cc-by-nc-nd.svgcreate mode 100644 images/cc-by-nc-sa.svgcreate mode 100644 images/cc-by-nc.svgcreate mode 100644 images/cc-by-nd.svgcreate mode 100644 images/cc-by-sa.svgcreate mode 100644 images/cc-by.svgcreate mode 100644 images/cc-zero.svgcreate mode 100644 images/favicon-16x16-next.pngcreate mode 100644 images/favicon-32x32-next.pngcreate mode 100644 images/logo.svgcreate mode 100644 index.htmlcreate mode 100644 js/algolia-search.jscreate mode 100644 js/bookmark.jscreate mode 100644 js/local-search.jscreate mode 100644 js/motion.jscreate mode 100644 js/next-boot.jscreate mode 100644 js/schemes/muse.jscreate mode 100644 js/schemes/pisces.jscreate mode 100644 js/utils.jscreate mode 100644 lib/anime.min.jscreate mode 100644 lib/font-awesome/css/all.min.csscreate mode 100644 lib/font-awesome/webfonts/fa-brands-400.woff2create mode 100644 lib/font-awesome/webfonts/fa-regular-400.woff2create mode 100644 lib/font-awesome/webfonts/fa-solid-900.woff2create mode 100644 lib/velocity/velocity.min.jscreate mode 100644 lib/velocity/velocity.ui.min.jsdelete mode 100644 placeholdercreate mode 100644 tags/Adobe/index.htmlcreate mode 100644 "tags/Adobe\345\256\211\350\243\205\351\224\231\350\257\257/index.html"create mode 100644 tags/Visual-Studio-Installer-Error/index.htmlcreate mode 100644 tags/index.htmlcreate mode 100644 tags/tutorial/index.htmlEnumerating objects: 91, done.Counting objects: 100% (91/91), pressing objects: 100% (66/66), done.Writing objects: 100% (91/91), 260.02 KiB | 6.84 MiB/s, done.Total 91 (delta 24), reused 0 (delta 0), pack-reused 0remote: Resolving deltas: 100% (24/24), done.To /yihuajack/yihuajack.github.io.git+ dd9b4c5...1d6cbde HEAD -> master (forced update)Branch 'master' set up to track remote branch 'master' from '/yihuajack/yihuajack.github.io.git'.INFO Deploy done: git

编辑<blog>/source/about/index.md即为“关于”页面。编辑<blog>/source/_posts下的相应Markdown文件即可编辑博文。在开头的Front-matter部分可以通过title编辑标题、date编辑日期、tags编辑标签、categories编辑分类。如果多条tags或categories使用语法:

categories:- Diarytags:- PS3- Games

参考官方文档:https://hexo.io/zh-cn/docs/。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。