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

Removing old posts after changing the export file name #717

Open
amca01 opened this issue Jul 9, 2023 · 2 comments
Open

Removing old posts after changing the export file name #717

amca01 opened this issue Jul 9, 2023 · 2 comments

Comments

@amca01
Copy link

amca01 commented Jul 9, 2023

I've been writing a few posts lately, and some posts have needed to be split into two, and hence the initial value of EXPORT_FILE_NAME has needed to be changed. So I might have, at the beginning of a post, something like:

:PROPERTIES:
:EXPORT_FILE_NAME: an_initial_name
:EXPORT_DATE: 2023-07-07
:END: 

When I export all of the org file (which contains all of my posts) to Hugo, I'll have a post corresponding to that file name. But suppose later I change the export file name:

:EXPORT_FILE_NAME: a_new_and_better_name

Now, when I export to Hugo, I have two blog posts with the same title (which hasn't changed), each corresponding to one of the exported file names.

How do I either (a) prevent this from happening, or (b) remove the old post? It's not enough to remove it from the public directory, as there may still be a link to it in index.xml.

(This may be more of a Hugo question than an ox-hugo question. But since all my interaction with Hugo is through ox-hugo, I thought I should ask here first.) Many thanks!

@kaushalmodi
Copy link
Owner

How do I either (a) prevent this from happening

There's no way. If you are modifying the EXPORT_FILE_NAME, the exported Markdown file name will change.

, or (b) remove the old post?

Yes, each time you modify the EXPORT_FILE_NAME, also remember to delete the old Markdown file from the content/ directory.

It's not enough to remove it from the public directory, as there may still be a link to it in index.xml.

I don't understand this. When you delete the old Markdown file from content/, Hugo will regenerate the whole public/ directory. So there shouldn't be any references to the old deleted file in index.xml.

Don't manually tweak the files in public/ because that whole directory gets regenerated by Hugo.


If you are managing the ox-hugo exports using git

If you change the EXPORT_FILE_NAME, you will notice that there are now 2 Markdown files (old and new) when you do git status. You can review that and delete the old file before you rerun Hugo.


This issue is also a duplicate of #34. If you follow the thread, someone chose to just delete the entire content/ directory and report all the Org files using ox-hugo each time. I don't recommend that though if you are changing only one file name at a time. It's much easier to be aware of the change and manually delete the old file.

ox-hugo remains to be conservative in nature such that it won't auto-delete anything; it will only export and create new files or modify existing files in content/ based on the changes in the Org files.

@kaushalmodi
Copy link
Owner

This may be more of a Hugo question than an ox-hugo question

If deleting the old Markdown file from content/ solves the problem, then this is not a Hugo issue.

It would be a Hugo issue if the index.xml had references to the old file even after deleting it from the content/ directory. Again, don't modify the files inside public/!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants