Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically enable Github Pages for a repository

Is there any way to enable Github pages through the api? Not requesting a page build, I mean the initial enabling of the feature and pointing to a branch.

like image 642
Dok Umansky Avatar asked Feb 05 '18 10:02

Dok Umansky


People also ask

Can GitHub Pages be dynamic?

No you can't. Github Pages does not support dynamic sites.

Can you use JavaScript in GitHub Pages?

GitHub Pages is a static site hosting service that takes HTML, CSS, and JavaScript files straight from a repository on GitHub, optionally runs the files through a build process, and publishes a website.


1 Answers

You just have to push content to the remote git repository.
You have to differentiate between a User-Page (username.github.io) and a Project-Page (username.github.io/projectname)

User-Page:

git clone https://github.com/username/username.github.io
cd username.github.io

echo "Hello World" > index.html

git add --all
git commit -m "Initial commit"
git push -u origin master

Project-Page:

git clone https://github.com/user/repository.git
cd repository

git branch gh-pages
git checkout gh-pages
echo "Hello World" > index.html

git add --all
git commit -m "Initial commit"
git push -u origin gh-pages
like image 129
Borian Avatar answered Sep 28 '22 13:09

Borian