Total Pageviews

Friday, 22 May 2026

如何push静态网站的根目录到your-username.github.io/abc?

 此问题困扰了我多年,今天无意中看到https://github.com/briteming/vuepress-web-app/blob/master/deploy.sh ,得到了启发。

以静态博客程序zola( https://briteming.blogspot.com/2020/03/rust-zola.html)为例。

我在windows机器上,安装了git-bash,然后安装了rust环境。按此文 https://briteming.blogspot.com/2020/03/rust-zola.html生成静态网站的根目录-public目录。

因为下面要把静态网站的根目录-public目录push到your-username.github.io/abc ,所以要编辑~/zola-site/config.toml文件,把base_url的值设为"/zola"

cd public
(此处的public为静态网站的根目录)
$ git init .
$ git add .
$ git commit -m 'xx'
$ git remote add origin git@github-second:briteming/zola
$ git push -f git@github-second:briteming/zola master:gh-pages
显示:
。。。
master -> gh-pages (forced update)
就表明push成功。然后访问briteming.github.io/zola即可看到网站效果。

注意:如果你有多个github帐号要做切换,请先阅读https://briteming.blogspot.com/2012/04/githubssh-key.html

你的仓库github.com/your-username/abc需要先被创建:

访问 https://github.com/your-username?tab=repositories, 然后访问https://github.com/new,创建空白仓库abc.

 

 

No comments:

Post a Comment