将静态博客部署到GitHub上

将博客部署到github上

以hugo为例,hexo有很详细的教程

这部分需要使用到一个叫做github page的东西,是GitHub提供的一个网页寄存服务,可以寄存静态页面,这个特性就特别适合博客的搭建。

首先再Github上创建一个 Repository,命名为–名字.github.io,这样就可以生成一个用户页面

在hugo server调式页面完成后,使用命令hugo生成hugo静态页面。

注意!!! 在生成静态页面之前要把config.toml文件中的baseURL修改为自己博客的网址,譬如

1
2
baseURL = "https://name.github.io/"
hugo ##生成静态页面文件

在命令执行后,出现一个public文件夹,里面就是网站的静态页面文件

进入public文件夹,使用git上传文件

1
2
3
4
5
6
cd public
git init ##初始化仓库
git remote add origin https://github.com/caecarxu/yourname.github.io.git ##链接远程仓库
git add .
git commit -m "first commit"
git push -u origin master

在此之后更新文章,使用hugo生成新的静态页面,并使用git push进行同步

1
cd public
1
git add .
1
git status
1
git commit -m "add blog post"
1
git push

提示以下,commit -m 后面的东西是此次提交的备注,通常用来说明提交人的名字