Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add preserve_hidden_files configuration option #1985

Merged
merged 8 commits into from
Nov 19, 2022

Conversation

flxzt
Copy link
Contributor

@flxzt flxzt commented Sep 11, 2022

This PR introduces a preserve_hidden_files configuration option. When this option is set to true, zola preserves all hidden ( starting with .) files and folders in the output directory when building the site.
It also changes that all files inside the output directory, but not the folder itself are deleted.

closes #1976 when merged.

Sanity check:

  • [x ] Have you checked to ensure there aren't other open Pull Requests for the same update/change?

Code changes

(Delete or ignore this section for documentation changes)

  • [x ] Are you doing the PR on the next branch?

If the change is a new feature or adding to/changing an existing one:

  • [x ] Have you created/updated the relevant documentation page(s)?

@flxzt flxzt force-pushed the preserve-hidden-files branch 2 times, most recently from 4193312 to e7ccec0 Compare September 11, 2022 03:21
components/site/src/lib.rs Show resolved Hide resolved
components/site/src/lib.rs Outdated Show resolved Hide resolved
components/site/src/lib.rs Show resolved Hide resolved
@tosti007
Copy link

I personally would like the feature where the public folder is kept and it's content are removed, but don't need the preservation of hidden files. Shouldn't be keeping the public folder be a seperate flag where the preserce_hidden flag implies keep_public? Another option would be make preserving the public folder default behavior, whcih ij turn would make the code here a bit simpler.

@flxzt
Copy link
Contributor Author

flxzt commented Sep 30, 2022

I would prefer that too and implemented it this way initially, but @Keats reviewed that the original code path should be preserved when the option is not set. My guess is to keep backwards compatibility in cases the folder is watched by other tools.

@tosti007
Copy link

tosti007 commented Oct 1, 2022

That makes sense! So would it be a good option to add a separate flag to keep the public folder?

@Keats
Copy link
Collaborator

Keats commented Oct 1, 2022

What's the usecase for wanting the public folder preserved but empty?

@tosti007
Copy link

I am running zola as a docker image to rebuild the site on file-change. However, things tend to break when a folder mounted to a docker image is removed. Hence, by removing the files rather than the entire folder, the public folder itself can be mounted. Currently I am running a rm and mv command after build to achieve the same.

@flxzt
Copy link
Contributor Author

flxzt commented Oct 20, 2022

what are your thoughts about this @Keats ?

@Keats
Copy link
Collaborator

Keats commented Nov 14, 2022

I think the current PR is fine, I'm just wondering about the naming. Files starting with . are not hidden on Windows so I think it might be confusing to people not used to Unix/Linux

@flxzt
Copy link
Contributor Author

flxzt commented Nov 14, 2022

How about renaming the option to "preserve_dotfiles" instead of "preserve_hidden_files"? Thats a term that is associated with configuration files, and does not imply anything about visibility. Is also a little shorter

@Keats
Copy link
Collaborator

Keats commented Nov 14, 2022

preserve_dotfiles_in_output? Just to give some context on the location

@flxzt
Copy link
Contributor Author

flxzt commented Nov 14, 2022

Okay, sounds good to me! I'll change it

@Keats
Copy link
Collaborator

Keats commented Nov 15, 2022

Looks like you need to do a manual rebase from the next branch

@flxzt flxzt force-pushed the preserve-hidden-files branch from 8308fa2 to 4b83e30 Compare November 15, 2022 16:03
@flxzt
Copy link
Contributor Author

flxzt commented Nov 15, 2022

ok, done

@Keats
Copy link
Collaborator

Keats commented Nov 17, 2022

So i believe just turning on this option will mean that the public folder will not be deleted, solving a few people issues as well.

@flxzt
Copy link
Contributor Author

flxzt commented Nov 17, 2022

Nice :) I should probably add this behaviour to to the documentation to make it more discoverable. Something like Enabling this also prevents the deletion of the output folder itself on rebuilds.

Edit: done.

@Keats Keats merged commit e282bc8 into getzola:next Nov 19, 2022
@Keats
Copy link
Collaborator

Keats commented Nov 19, 2022

Thanks!

@flxzt flxzt deleted the preserve-hidden-files branch February 23, 2023 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants