I build my site to a separate repo (GitHub Pages). If I delete a source markdown page, I want the corresponding built HTML page to be deleted during the build.
I’m familiar with --cleanDestinationDir (hugo usage). The undesirable result of that option is that each commit of the built site deletes every file and then adds every file. This seems a bit inefficient, but it also means I can never see a diff of my builds.
I’m also familiar with the default behavior around draft, publishdate, and expirydate. However, I don’t see how expirydate is useful if the default behavior doesn’t remove the built page that has expired. In order for the expirydate behavior to be useful, don’t you have to also use the --cleanDestinationDir option? If so, the documentation should mention this.
My current solution is to build to a temporary directory, then use rsync between the tmp build directory and the final repo destination. This ensures that a page that was not built to the tmp directory will actually get deleted (using the --delete option for rsync) from the final repo.
However, now I’m dealing with .gitignore getting deleted and unwanted files in my build directory.
Can anyone comment on this general approach or share their solutions? Is there a better way to do this? I feel like I shouldn’t need rsync to make this work the way I want. Thoughts?
The solution I’m hearing from you guys is to not care about the commit history of my generated site. That’s fair. I’ll consider that. However, I still use the commit review to spot-check that the build worked as expected. I guess I’m paranoid about that. I’ve been burned enough times by various anamolies in my own setup.
That said, the core of my question is really around the use of --cleanDestinationDir and expirydate. Is it accurate to say that --cleanDestinationDir is the recommended way to remove pages from the built site? From what I can tell, expirydate and draft: true on their own will not remove a previously built page.
I have to agree with others here, checking in built assets seems completely wrong to me.
If you’re looking to prevent broken releases to your production server then set up deploy preview branches. I have a protected main branch that deploys to production, whilst my develop branch deploys on push. If that breaks, I don’t merge develop into my production branch. Git flow is your friend.
I’ll reiterate that my question is not really about .gitignore or where to build my site. My question is about how to delete a page from the built site.
That said, the core of my question is really around the use of --cleanDestinationDir and expirydate . Is it accurate to say that --cleanDestinationDir is the recommended way to remove pages from the built site? From what I can tell, expirydate and draft: true on their own will not remove a previously built page.