peaceiris/actions-hugo

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:

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.

  1. Add docs to the .gitignore file
  2. Run git rm -r --cached ./docs
  3. Add, commit and push the changes.

In addition, it may be useful to check the current setting.

Screen Shot 2021-05-06 at 0 20 35

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!

This issue has been LOCKED because of it being resolved!

The issue has been fixed and is therefore considered resolved.
If you still encounter this or it has changed, open a new issue instead of responding to solved ones.