初次本地体验Hexo
创建一个hexo文件夹保存内容
hexo init(initial:初始化)
hexo g(generate:生成)
hexo s (hexo server:启动本地服务预览)
复制出现的 http://localhost:4000 到浏览器可以看到效果
注意:如果电脑没有显示可能是端口被占用,使用hexo s -p 5000换个端口,网址的4000换成5000即可。
配置Hexo
打开根目录下的_config.yml文件开始配置
界面:最上面可以找到title(标题)然后下面的都是可以写的,根据个人喜好配置。注意language可以用zh-Hans就可以显示中文。
主题:找到theme后面改成next,等下会配置此主题
开启搜索选项: npm install hexo-generator-searchdb --save
-
部署:配置好后方便后续的推送,找到deploy 格式如下
type: git
repo: git@github.com:youname/yourname.github.io.git
branch: master npm uninstall hexo-toc --save
Hexo的简单配置完成
下载及配置Next主题
Next下载(在根目录下输入):git clone https://github.com/iissnan/hexo-theme-next themes/next
-
简单配置
风格:找到Schemes Pisces不错,去掉前面的#使用
头像:在最后添加avatar: /images/yours.png
搜索选项:Local search enable改为true
-
新建和推送
新建:hexo new (布局--开头需要那些东西可以直接生成,在scaffolds文件夹中,我写了一个c.md)名字(生成.md文件,生成时间和标签头)例子:hexo new c 数据结构)
推送:hexo g(生成动态文件)--->hexo s -p 5000(预览)--->hexo deploy(部署)
插件&扩展
- 添加tags以及categories,使用方法
<pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="" cid="n78" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">hexo new page tags
在source/tags/index.md中找到文件index.md,添加一行
type: "tags"</pre>
<pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="" cid="n79" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">hexo new page categories
在source/categories/index.md中找到文件index.md,添加一行
type: "categories"</pre>
<pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="" cid="n80" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">文章模板中添加
tags:hexo
categories: 学习有感
效果如下</pre>
-
上传整个hexo目录到git
主要是主题next要注意,删除clone仓库的.git目录:rm -rf .git
-
回到自己的仓库
git rm -r –cached ./
git add .
git commit -m “”
git push
增量更新