Does Hugo -d overwrite all existing files?

After a very frustrating experience trying to get my Hugo site on GitHub Pages via submodule and subtree, I have gone a different route. I now make changes and push my source to a source repo. THEN I build the site with ‘hugo -d …/production-folder’ and run a completely separate git instance there to add/commit/push the site to a production repo.

So if I delete the files/folders in the production folder every time I build the site, then I remove and add all of the files again when I git add/commit/push. I’d rather not do all of that duplicative work, so I was just wondering about the details of how ‘hugo -d’ handles overwriting.

1 Like

Hugo does not delete anything, but it will overwrite. But I prefer to separate prod from dev:


hugo -d dev

I’m using /source for developing and /production for production. I do hugo -d ../production each time I’m ready to push the working site up to GitHub.

Just looking for ideas on how to avoid massive commits, that’s all…

Only commit your source.

My source doesn’t have a /public folder - so I have my source on GitHub, but only for a backup.

I push my /production folder to a different repo using a gh-pages branch so that the site is hosted by GitHub. It is a completely separate repo, so without adding or committing there would be nothing to push…which would rather defeat the purpose.

So, what’s the main issue here? Is it that Hugo doesn’t delete stale content? Why are your commits “massive”?

I build into the production destination folder, I add/commit/push. I make a change, I build into the production destination folder. I add and commit again, and git sees that I am removing every file and adding every file. That’s thousands of in-and-out items in the commit.I’m not sure, but I suspect it also pushes the entire folder back to GitHub again. I’m trying to simplify all that, but not sure if it can be done…

Removing a file from your git tree and then generating the exact same file should not show up as a change to git. Have you looked at the diffs? What’s changing? Read this thread.

Based on that thread, the theme I’m using (grid-side) has a Section-based menu. I was struggling w/ the sort order, but it looks like adding weights would probably take care of that - thanks!

I added some menu items, added one page, deleted 8 others, commited. Commit stats show:

  • 242 files changed
  • 12480 insertions
  • 374 deletions

The files changed all have two separate lines show up while the commit is processing, both basically telling me that the LF will be replaced by CRLF. I think I’ve read somewhere how to turn that off but haven’t implemented it yet.

The push wrote 331kb, which seems like a lot for adding a page and some menu items…