- Go to your GitHub repository in your web browser.
- Click on the "Settings" tab.
- Scroll down to the "Pages" section under the "Code and automation" section.
- Under "Source," choose the branch you want to use for GitHub Pages (e.g., main).
- If your HTML files are in a /docs folder, select /docs as the folder; otherwise, select / (root).
- Click "Save." GitHub will provide a link to your site.
- In your repository/VSCode, create a folder called .github and then a subfolder called workflows.
- Inside the workflows folder, create a file named deploy.yml.
- Open the deploy.yml file and add the following content
name: Deploy to GitHub Pages
on: push: branches: - main
jobs: deploy: runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./ # Use ./docs if your files are in a docs folder
- Run the following commands to add and commit the workflow file:
- Go to your GitHub profile in your web browser and click on your profile picture in the top right corner.
- Select "Settings" from the dropdown menu.
- In the left sidebar, click on "Developer settings."
- Click on "Personal access tokens," then click "Tokens (classic)."
- Click on the "Generate new token" button.
- Add a note (e.g., "GitHub Pages Deploy Token") and select the scopes you need (you can start with repo for full control of private repositories).
- Click "Generate token."
- Copy the generated token and save it somewhere (Repo Secrets Next Step), as you won’t be able to see it again.
- Go to your GitHub repository in your web browser.
- Click on the "Settings" tab.
- In the left sidebar, click on "Secrets and variables" and then select "Actions."
- Click the "New repository secret" button.
- For the Name, enter GITHUB_TOKEN.
- For the Value, enter your GitHub personal access token. (To create a token, follow the next steps.)
- Click "Add secret."
- To update your website, make changes to your HTML files locally.
- Run the following commands to add and commit your changes: