gitignore the build directory in master/main?
bradryanbice opened this issue · 6 comments
Note that an issue which does not follow the template will be closed silently.
Check list before opening this issue
- I read the latest README of this repository.
For users of the GitHub Pages Action:
- I checked Available Options
- I followed Tips and FAQs
- I tried Workflow Examples
Describe your question
I am currently pushing my Hugo site changes to master, which is then using this Action to build a Github Page to a gh-pages
branch, using a ./docs
publish_dir
.
It seems my site will not build correctly unless I fully build, commit, and push the entire /docs
publishDir
in Hugo. Which also means I'm having to track that entire directory with any change to my source.
It seems I'm doing something wrong here, and that should not be necessary. Am I correct, and is there a way to .gitignore
my /docs
directory in the master
branch? Would I use something like exclude_assets
in this case?
I think you are having the docs
folder under Git control. We do not need to put the built files under Git control. As a workaround, you can run hugo --cleanDestinationDir
to delete docs
each running.
To remove the docs
folder from Git control completely, you can run the following commands.
- Add
docs
to the.gitignore
file - Run
git rm -r --cached ./docs
- Add, commit and push the changes.
Ok, should I not have publish_dir: ./docs
in my gh-pages.yml
then?
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: ./docs
If your publishDir
(Hugo's config) is docs
, keep that workflow.
Ok, this seems to have worked. I swear I did this before but I must have missed something crucial. Thank you!