在
效果预览:https://www.example.com/personal-website
准备:
- 一台Windows电脑。
- 注册GitHub账号,使用hexo框架搭建网站。
参考网址:
- GitHub安装:https://github.com/
- Git教程:https://git-scm.com/
安装过程:
(1)Node.js 安装
- 按照官方安装过程依次点击即可,安装过程很简单。
- 安装完成后,执行以下命令检查是否安装成功:
node -v npm -v
(2)Git安装
- 在网上查找适合自己系统的安装方式。
- 安装完成后,同样使用以上命令检查是否安装成功。
搭建Hexo博客:
-
安装淘宝镜像源:
npm install -g cnpm --registry=https://registry.npm.taobao.org
-
创建GitHub仓库(repository):
- 建议以个人姓名或英文名字命名为仓库名,例:hansonpang99.github.io。
-
安装Hexo部署插件:
cnpm install --save hexo-deployer-git
-
修改_config.yml文件:
- 打开Blog目录下的_config.yml文件。
- 找到以下代码段并修改:
deploy: type: git repo: <repository url> branch: <branch name>
- 修改
repo
为刚刚创建的GitHub仓库地址,例如:https://hansonpang99.github.io。 - 修改
branch
为主分支名,一般为master
。
- 修改
-
本地文件部署到GitHub:
hexo d
-
访问https://${你的GitHub仓库名称},即可访问已部署的网站。
深化操作过程:
更换博客主题
以Yilia为主题为例进行讲解:
-
下载yilia主题:
git clone https://github.com/litten/hexo-theme-yilia.git themes/yilia
-
修改_config.yml文件:
- 同样打开_config.yml文件。
- 找到以下代码段并修改:
theme: <theme name>
- 将
<theme name>
改为下载的主题名,例如:yilia。
- 将
-
清理数据库和生成静态网站:
hexo clean && hexo generate
-
再次部署到GitHub:
hexo d
这样,你就可以完成个人快速建站的整个流程了。希望本文能对你有所帮助!