zola
zola copied to clipboard
Only delete contents of public folder to avoid breakage when the folder is a git submodule
Bug Report
Environment
fedora 36
Zola version: 0.16.1
Expected Behavior
The zola build should only delete the contents of the public
directory instead of deleting it completely.
Current Behavior
The entire public folder is deleted. When the public directory is a submodule pointing to another repository (e.g. when the site is deployed via github pages), currently it then breaks the git submodule. I believe this could be prevented when only the contents of the directory are deleted.
EDIT: to be more precise, the issue seems to be that it removes the .git
file from the submodule directory. It might be preferable to ignore it, or ignore all hidden files?
Step to reproduce
- have the public directory as a git submodule
- run
zola build
The public
directory is meant to be generated and published so it shouldn't contain things like git folders in the first place?
I have the public directory as a separate public repository which then gets deployed via github pages. My configuration repository can then be private and the public repository is added as a submodule.
When doing this, git moves the .git directory of the submodule into .git/modules/
of the parent repository and replaces it with a .git file which contains the path of the new location. This file should not be deleted because it then breaks the submodule.
So couldn't it be a sensible default to preserve the folder and the hidden files, or if you are open to a little bit of bloat to add a flag like --preserve-hidden
or even a white-list?
I suppose using a github action as described in the docs would work too, but I like to keep things as simple as possible.
I hope this makes sense, and for more context why I set it up like this: I transitioned to zola from hugo, where this configuration is supported.
@Keats if you are not opposed to this and @flxzt doesn't mind waiting a while until I can get some time. I wouldn't mind trying to implement it using a suitable field in the config.toml
. I'm also fine with someone else doing it if @Keats is not opposed as I don't know yet when I will have time to do it and can pick up another issue when I do have time.
Wouldn't the .git files be exposed by the webserver then?
I could not find any documentation, but from testing I have found that github pages does not serve the .git directory but it does serve other .*
files. For other webservers it obviously depends how they are configured, but I believe denying hidden files is common because of other configuration files like .htaccess
or .env
If I may add to this, it would be a very useful feature. Similar to @flxzt , I use Codeberg pages for some sites, and my .git
folder and .domains
file get deleted on build
I'm working around it for now by having a separate "deploy" folder with my .git
and .domains
files in that I copy the content of public to, but it would be great not to have to do this.
I'll jump in again, I've just realised we can creatively use the static
folder for files such as .htaccess
, .domains
and the like.
it's probably not ideal for the /(github|codeberg)/.pages
.git
folder, but it gets around quite a annoyance hurdle for me
If it's an opt-in option then it's fine to add
ok great! I created a PR for it.