效果预览:https://yourwebsite.com 准备:

  1. 所需工具

    • Windows电脑
    • 账号使用GitHub
  2. 搭建个人网页步骤

(1)安装Git

  • 参考网址:git安装教程

    安装过程:(1)按照网上的安装方式进行安装就可以。

(2)安装Hexo


检测hexo是否安装成功:

hexo version # 返回版本号

  1. 搭建网页环境

a) 安装淘宝的镜像源(如果无法连接就多试几次):

npm install -g cnpm --registry=https://registry.npm.taobao.org 

b) 建立仓库(repository)

  • 输入以下命令,创建一个新的GitHub仓库(例如:yourusername.github.io)。

    git clone https://github.com/yourusername/yourusername.github.io.git
    

c) 安装Hexo部署插件

cnpm install --save hexo-deployer-git

  1. 配置Blog目录下的_config.yml文件(推荐使用VisualStudioCode打开)

a) 找到博客根目录下的_config.yml文件,并按照以下步骤进行修改:

  • 修改type为git

  • 修改repository为你的GitHub仓库地址:https://github.com/yourusername/yourusername.github.io.git

  • 修改branch为master

b) 保存配置文件


  1. 部署到GitHub
  • 在根目录下输入以下命令,将本地文件部署到GitHub上的仓库中。

    hexo d 
    

  1. 访问你的个人网页

  1. 进一步深化操作,更换主题(以yilia主题为例)

a) 下载yilia主题

git clone https://github.com/litten/hexo-theme-yilia.git themes/yilia 

b) 修改_config.yml文件,找到theme字段,将其内容修改为 themes/yilia/yilia.lite

c) 清理数据库,重新生成静态网站

hexo clean && hexo g && hexo d

通过上述步骤,你就可以快速建立一个个人网页了。开始你的网络之旅吧!