搭建个人博客
基础安装和使用
下载nodejs和npm
安装hexo
1 | nmp install -g hexo-cli |
使用hexo
在你想要创建博客的目录下执行以下命令:
1 | hexo init |
这会在当前目录下创建一个新的hexo项目。
常用命令
1 | hexo new "post title" # 创建一篇新的文章 |
部署到github
github创建仓库
仓库名为username.github.io
,其中username为你的github用户名。
安装部署到github的依赖
1 | npm install --save hexo-deployer-git |
修改hexo配置文件
修改_config.yml
文件,修改以下内容:
1 | # Deployment |
此时使用 hexo d 即可将博客部署到github上。
主题美化
安装主题
在hexo目录下执行以下命令来安装next主题:
1 | npm install hexo-theme-next |
升级主题
1 | npm install hexo-theme-next@latest |
配置文件
1 | # Installed through npm |
修改hexo配置文件
打开_config.yml
文件,修改以下内容:
1 | theme: next |
修改主题配置文件
打开_config.next.yml
文件,修改以下内容:
1 | # Allow to cache content generation. |
配置标签功能
在根目录下输入
1 | hexo new page tags |
默认在source\tags\index.md
中创建
修改index.md
文件,添加以下内容:
即添加type: “tags”
1 | --- |
修改_config-next.yml
文件,修改以下内容:
1 | # themes\scallop\_config.yml |
在文章中添加tags标签即可
1 | --- |
安装搜索功能
安装搜索插件
1 | npm install hexo-generator-searchdb |
修改hexo配置文件
打开_config.yml
文件,添加以下内容:
1 | search: |
修改主题配置文件
打开_config.next.yml
文件,添加以下内容:
1 | # Local search |
安装评论功能
使用LiveRe
登录LiveRe并安装
安装完成后找到data-uid
复制data-uid = 后的内容
修改主题配置文件
打开_config.next.yml
文件,添加以下内容:
1 | # Support for LiveRe comments system. |
外部库功能
fancybox和mediumzoom不要同时启用
1 | # Easily enable fast Ajax navigation on your website. |