Github是一个用来保存源代码的服务。本文介绍利用Github的创建一个完全免费的静态网站的方法,有两个好处:- 完全免费- 可以保存网站的不同版本本文是通过Mac OSX的终端软件进行操作的。
工具/原料
1
github账号
2
git软件
准备
1
创建一个新的repository。
2
通过终端命令行在本地创建一个repository。mkdir mywebsitecd mywebsitegit initecho '# mywebsite' >> README.mdgit add README.mdgit commit -m 'first commit'git remote add origin https://github.com/username/mywebsite.gitgit push -u origin master注意:username改为你自己的用户名。
3
创建一个“孤儿”分支:git checkout --orphan gh-pages
添加网站文件
1首页
首先创建一个index.html:
我的首页
2
添加到git repository中:git commit -a -m 'Adding pages'
3
然后存储(push)到repository中:git push origin gh-pages
4
在浏览器中http://username.github.io/mywebsite/注意:username替换为自己的用户名
注意事项
可以通过CNAME设置自己的域名。
上一篇:免费网站建设具体操作步骤