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

force flag for hugo new (not hugo new site) #9243

Closed
DanielRuf opened this issue Dec 3, 2021 · 2 comments · Fixed by #10237
Closed

force flag for hugo new (not hugo new site) #9243

DanielRuf opened this issue Dec 3, 2021 · 2 comments · Fixed by #10237

Comments

@DanielRuf
Copy link

We already have --force for hugo new site but it seems this flag is not available for hugo new to create content.

I have looked at all the issues there and I can not see any relevant issue or PR:
https://github.com/gohugoio/hugo/search?p=15&q=force&type=issues

I have the following usecase:

A specific content type as template. ENV_VAR=value hugo new my-new-file-name -k my-template-type to populate the frontmatter with custom keys and values and create the new file.

But if I want to update the content in a specific environment I want to run ENV_VAR=other-value hugo new my-new-file-name -k my-template-type to recreate it for compilation.

And if my template-file changes, then I want to just run it with the old ENV_VAR=value hugo new my-new-file-name -k my-template-type but get the new template in the resulting file.

Currently this does not work as Hugo says "file-name already exists".
Even the --force option for sites does not overwrite files but only folders. See https://github.com/gohugoio/hugo/blob/master/commands/new_site.go#L89 (seems to only add new files but not overwrite existing files).

Maybe such an option to overwrite files should be added for the site command too.

My current workaround is to do a rm file-name and then run ENV_VAR=other-value hugo new my-new-file-name -k my-template-type again.

@bep bep added this to the v0.91.0 milestone Dec 8, 2021
@onedrawingperday
Copy link
Contributor

onedrawingperday commented Dec 9, 2021

Yes, a way to overwrite existing files with hugo new would be very useful and it has been bugging me also for a while.

@bep bep modified the milestones: v0.91.0, v0.92.0 Dec 20, 2021
@bep bep modified the milestones: v0.92.0, v0.93.0 Jan 12, 2022
@bep bep modified the milestones: v0.93.0, v0.94.0 Mar 1, 2022
@bep bep modified the milestones: v0.94.0, v0.95.0, v0.96.0 Mar 9, 2022
@bep bep modified the milestones: v0.96.0, v0.97.0 Mar 24, 2022
@bep bep modified the milestones: v0.97.0, v0.98.0 Apr 13, 2022
@bep bep modified the milestones: v0.98.0, v0.99.0 Apr 28, 2022
@bep bep modified the milestones: v0.99.0, v0.100.0 May 24, 2022
@bep bep modified the milestones: v0.100.0, v0.101.0 May 31, 2022
@bep bep modified the milestones: v0.101.0, v0.102.0 Jun 16, 2022
@bep bep modified the milestones: v0.102.0, v0.103.0 Aug 28, 2022
satotake added a commit to satotake/hugo that referenced this issue Aug 31, 2022
@bep bep closed this as completed in 7d40da8 Sep 8, 2022
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants