Utiliser une branche gh-pages
Cette leçon est affichée en anglais, car elle n'a pas encore été traduite.
Draft: this lesson is an outline and will be expanded.
A branch is a separate line of saved changes in your repository. Many projects keep their finished site, ready to serve, on a branch of its own called gh-pages. A hosting service then reads only that branch. You build the site once, and any platform can pick up the result. This is how the site you are reading is published.
What you will do
- Read how this site does it. Its workflow file,
.github/workflows/fullstack-deploy-gh-pages.yml, builds the site, checks it, and pushes the finished files to thegh-pagesbranch. - Look at what that branch holds at its top level: a file named
esa.jsonc, a file namedwrangler.jsonc, and the folderdist/with the built site. The two small files tell two different hosting services what to serve. - Open
esa.jsonc. It gives the site a name and says to serve the./distfolder. Its install and build commands do nothing, because the site is already built. - Ask your AI assistant: “Change my workflow so that it builds my site and pushes the finished files to a
gh-pagesbranch.” Read its answer before you accept it. - Push, wait for the run, and open the
gh-pagesbranch on GitHub. Look at the files it holds.
The gh-pages branch is rewritten on each publication, so it keeps no history. Your real work and its history stay on the main branch. Never edit the gh-pages branch by hand.
Check yourself
- You can say why a finished site is kept on its own branch.
- Your repository has a
gh-pagesbranch that holds only the finished files. - You can find the main branch history untouched after a publication.