I’m having trouble with deploying hugo to github pages. I’ve followed the step-by-step instructions listed here https://gohugo.io/hosting-and-deployment/hosting-on-github/ and I successfully set up a git submodule to send my public files over to my github pages repo. The first time I ran the deploy script it worked like a charm and the public files were pushed to wileybaba.github.io. However, after making small content updates, and running the script again, my public folder was pushed to the repo that contains my source files and content. Any ideas?
Hi — do you have a git repo we can look at? Else this is hard to troubleshoot from afar.
Update: I see the repo that holds your generated site files, but where is the repo that holds your Hugo source files?
To prevent your
public/ folder from being committed to your hugo source repo, you need to add a
.gitignore file, then tell it to ignore
# Hugo public/
For a deeper dive on the
.gitignore file, see this atlassian article.
The repo with my source files and content is here:
If I create that gitignore file, that won’t prevent the public files from being pushed to the repo with my generated files?
Correct. It will only affect which files are to live in your hugo source repo.
Okay cool, I’ve got that file, but now when I run my deploy.sh script, changes are pushed to the source repo but the public files are not pushed to the generated site file repo
When you ran step #6 from the docs, it should have created a
.gitmodules file. I don’t see this file in your source repo.
I have a .gitmodules file in my repo, but when I run the deploy script from my machine, it only pushes to the source repo. Also, despite the presence of a .gitignore file in my root directory, public is still being pushed to the source repo and nothing is being pushed to the generated files repo. Thanks for the handholding, I’ve even deleted all the repos and started over but am running into the same issue.
Show us the console output of your
Also, in the script, instead of
git add ., do a
git add -A.
git add -A – will stage all changes.
git add . – will stage new files and modifications, without deletions, which would explain why your
public/ folder was not being removed.
Wileys-MacBook-Pro:wilito wileyconte$ deploy.sh Deploying updates to GitHub... | EN | ES +------------------+----+----+ Pages | 9 | 5 Paginator pages | 0 | 0 Non-page files | 0 | 0 Static files | 36 | 36 Processed images | 0 | 0 Aliases | 1 | 1 Sitemaps | 2 | 1 Cleaned | 0 | 0 Total in 252 ms [master 62173d7] rebuilding site Thu Nov 1 13:20:53 MDT 2018 1 file changed, 1 insertion(+), 1 deletion(-) Enumerating objects: 7, done. Counting objects: 100% (7/7), done. Delta compression using up to 4 threads Compressing objects: 100% (4/4), done. Writing objects: 100% (4/4), 395 bytes | 395.00 KiB/s, done. Total 4 (delta 3), reused 0 (delta 0) remote: Resolving deltas: 100% (3/3), completed with 3 local objects. To https://github.com/wileybaba/wilito.git 089ee6b..62173d7 master -> master
Hmm, if you run
git status from within
public/ what do you see?
Wileys-MacBook-Pro:public wileyconte$ git status On branch master Your branch is up to date with 'origin/master'. nothing to commit, working tree clean
The gitsubmodule doesn’t seem to be doing its job…very strange because the first time I deployed with the script all went well and the public files were pushed to the github page repo
Yeah, it’s odd. I would have expected the output of
git status to say you have local commits that needed to be pushed.
Thanks for your help, I’ll keep tinkering around and can always force the commits in the meantime.
Update: Solved this issue by deleting my git .index file, and the .gitmodules file and starting over with the git add submodule at step 5.
What is the
A binary file that lives inside the git folder that holds information on your directories path names. I don’t know much about it but deleting it and running
git init again seemed to resolve this issue.
A post was split to a new topic: Help with deploying