1、创建GitHub账号

GitHub地址:https://github.com/
点击Sign up创建账号
如果已创建,点击Sign in登录

2、创建仓库

假设Owner为username,则Repository name为username.github.io

说明:
1、Owner为用户名
2、Repository name为仓库名,格式为:用户名.github.io

图片

图片

图片

图片

图片

3、配置SSH-Key

3.1、生成SSH密钥

ssh-keygen -t rsa -f ~/.ssh/github_id_rsa

3.2、查看SSH公钥

cat ~/.ssh/github_id_rsa.pub

3.3、部署公钥

详见:
https://gitee.com/help/articles/4181#article-header0
https://docs.github.com/zh/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent

4、克隆项目

git clone git@github.com:username/username.github.io.git

5、创建文件

cd username.github.io
echo "Hello World" > index.html

6、提交文件

git add .
git commit -m "Initial commit"
git push -u origin main

7、浏览器访问

浏览器访问域名:username.github.io

8、配置CNAME

如果不想配置CNAME,忽略以下操作。

8.1、以阿里云域名为例,配置CNAME

图片

图片

8.2、给GitHub的username.github.io仓库配置自定义域名

图片

图片

8.3、查看GitHub的username.github.io仓库

发现仓库多了一个文件,文件名为CNAME,文件内容为自定义的域名

8.4、浏览器访问

1、访问自定义域名username.xxx.yyy
2、访问username.github.io会跳转到username.xxx.yyy

9、详见

https://pages.github.com/
https://docs.github.com/zh/pages
Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐