效果预览:https://your-unique-url.github.io准备:
- Windows电脑。
- GitHub账号。
过程详解:
一、安装GitHub
参考网址:Git官网
具体步骤如下:
(1)Node.js安装
按照安装过程依次点击即可,安装过程很简单。
(2)安装Git
按照网上的安装方式进行安装就可以了。
参考网址:Git安装教程
二、配置淘宝镜像源
如果错误就重来,因为连接可能不稳定,不要害怕多试几次就可以了。
npminstall-gcnpm --registry=https://registry.npm.taobao.org
三、创建GitHub仓库
(示例:your-username.github.io)
四、安装Git部署插件
npm install hexo-deployer-git --save
五、配置_config.yml文件
- 使用编译器打开Blog目录下的_config.yml文件,建议使用Visual Studio Code。
优点:
- 支持的语言种类多。
- 视图简洁。
- 拥有插件种类多。
找到以下代码:
deploy:
type: git
repo: <repository url>
branch: [branch name]
将以上代码进行修改:
- 将
type
设置为github
,便于识别。 repo
替换为你的GitHub仓库地址。branch
设置为默认的master
分支。
保存后进行部署。
六、访问你的个性化网址
通过访问’https://your-username.github.io’就可以访问你的GitHub Pages了。
七、更换主题
以下以"next"主题为例说明如何更换:
- 下载next主题
git clone https://github.com/theme-next/hexo-theme-next.git themes/next
-
在_config.yml文件中修改theme字段,将其设置为刚刚克隆的next主题。
-
清除数据库
hexo clean
- 生成静态网站
hexo generate
- 部署到GitHub Pages
hexo deploy
这样,你就成功更换了博客的主题。