效果预览:https://your-personal-site plataforma.io
准备:1. Windows电脑.
2. 注册GitHub账号使用Jekyll框架搭建个人站点准备(1)Githttps://git-scm.com/ 参考网址:Git安装 https://www.cnblogs.com/sin-ssh-key-link-github-photo-tor.html
3. Node.js https://nodejs.org/en/ 安装过程:(1)Node.js安装按照安装过程依次点击即可,安装过程很简单。(2)安装Git安装过程与网上方式一致https://www.cnblogs.com/sin-ssh-key-link-github-photo-tor.html
(以下操作均在Jekyll中进行):
检测Node.js安装是否成功:
node -v (返回版本号)
npm -v (返回版本号)
安装淘宝的镜像源(如果错误就重来,因为连接可能不稳定,不要害怕多试几次就可以了):
npm install -g cnpm --registry=https://registry.npm.taobao.org/
创建一个新的GitHub仓库(repository)(例:yourusername.github.io)
在“个人站点”目录下安装Jekyll生成插件:
cnpm install --save jekyll-gem --production
找到“个人站点”文件中的_config.yml文件,使用编译器打开,建议使用VisualStudio Code打开。注意:Visual Studio Code的好处:1. 支持的语言种类多,视图简洁,拥有插件种类多。
找到这部分代码,(原始的是没有repo、branch的,而且type后面也没有东西)对这段代码进行更改:
type: git
repo: https://github.com/yourusername/yourusername.github.io.git
branch: master
修改保存以后进行本地预览:在终端输入:
jekyll server
访问 http://localhost:4000 即可看到效果。
进一步深化操作过程(更换主题):
首先下载你喜欢的主题,例如:
git clone https://github.com/your-theme-author/your-theme-name.git themes/your-theme-name
然后进入“个人站点”文件夹中的“_config.yml”,在配置文件中找到:
theme: your-theme-name
将其修改为你刚刚下载的主题名。
执行以下命令来清除并生成新的静态页面:
jekyll clean // 清理数据库之类的操作
jekyll generate // 生成静态网站
jekyll deploy // 部署到GitHub上
经过上述步骤后,你便可以在 http://yourusername.github.io 下看到你的站点了。至此,我们已经成功地用零费用搭建了一个个人站点。