效果预览:https://your-personal-website.com准备:
- Windows电脑
- 注册GitHub账号
- 准备(1)使用GitHub进行网站搭建准备(2)
参考网址:
- GitHub安装指南 https://github.com/
- SSH Key 连接教程 https://www.example.com/sing-ssh-key-link-github-photo-tour/
- Node.js下载安装 https://nodejs.org/en/
安装过程:
- (1)Node.js安装:按照安装步骤依次点击即可,安装过程很简单。
- (2)安装Git:按照网上指导进行安装即可。
———————————————————————————————————————检测Node.js安装是否成功:
node -v
npm -v
———————————————————————————————————————安装淘宝的镜像源(如果错误就重来,因为连接可能不稳定,不要害怕多试几次就可以了)
npm install -g cnpm --registry=https://registry.npm.taobao.org
建立仓库(repository):
- 创建一个GitHub仓库(例如:your_username.github.io)
在网站目录下安装一个部署插件:
cnpm install --save hexo-deployer-git
找到网站根目录下的_config.yml文件,使用编译器打开,建议使用Visual Studio Code打开。
注:Visual Studio Code的好处:
- 支持的语言种类多。
- 视图简洁。
- 拥有插件种类多。
找到这部分代码,进行更改:
type: git
repo:
repository: your_username.github.io
branch: master
更改后保存文件,然后运行以下命令将本地文件部署到GitHub上的仓库中:
hexo d
然后通过访问 https://your_username.github.io 即可访问你搭建的个人网站。
进一步深化操作过程(更换网站主题):
- 以“Next主题”为例进行更换
下载Next主题:
git clone https://github.com/iissnan/hexo-theme-next.git themes/next
找到根目录下的_config.yml文件,使用编译器打开,建议使用Visual Studio Code打开。
找到这部分代码(即theme),将冒号后面的内容改为刚刚新建的“next”:
theme: next
执行以下命令:
- 清除数据库等:
hexo clean - 生成静态网站:
hexo generate - 部署到GitHub中:
hexo d
这样就实现了主题的更换。
通过以上步骤,你就可以创建一个属于个人的网站了。