* 没有域名和服务器的前提下,怎么可以访问到我们的网页呢? 可以把网页代码托管在github,同样可以以站点的方式访问。 实践网址示例: https://411forget.github.io/shufa.github.io/
1、准备条件
- 注册一个github账号
- 安装Git
- 在github创建一个存储库,用来存放我们页面的相关代码文件
![bad4a610a558b6d68ed4060c381ada57.png](https://img-blog.csdnimg.cn/img_convert/bad4a610a558b6d68ed4060c381ada57.png)
2、git的操作方法
…or create a new repository on the command line
echo "# yufa.github.io" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin git@github.com:411forget/shufa.github.io.git
git push -u origin master
…or push an existing repository from the command line
git remote add origin git@github.com:411forget/shufa.github.io.git
git push -u origin master
…or import code from another repository
You can initialize this repository with code from a Subversion, Mercurial, or TFS project.
Import code
3、将本地网页的所有代码文件都push到github上
*注意:将需要将主页的html文件命名为index.html*
![dd63ac5d6b4bc2984f24210d1260cf3d.png](https://img-blog.csdnimg.cn/img_convert/dd63ac5d6b4bc2984f24210d1260cf3d.png)
最后的文件全部push上去的效果如下:
![44870cdd5f8d1c5062daadba7cf980f9.png](https://img-blog.csdnimg.cn/img_convert/44870cdd5f8d1c5062daadba7cf980f9.png)
4、现在可以打开网址看一下效果
具体网址是什么?
![25cead97c4d69c113afbc820fbd19aae.png](https://img-blog.csdnimg.cn/img_convert/25cead97c4d69c113afbc820fbd19aae.png)
![0feacd19c6de07d024d3a6e26e6e4d77.png](https://img-blog.csdnimg.cn/img_convert/0feacd19c6de07d024d3a6e26e6e4d77.png)
如果打不开网址:可能是pages还是none的状态,自己设置下即可
![9c1b698663bc250df8d9e3cd5e377e33.png](https://img-blog.csdnimg.cn/img_convert/9c1b698663bc250df8d9e3cd5e377e33.png)
网址打开后的效果图:
![75dfd6f6b0364bf2ba1be8078641e13f.png](https://img-blog.csdnimg.cn/img_convert/75dfd6f6b0364bf2ba1be8078641e13f.png)