kaushalmodi / ox-hugo

A carefully crafted Org exporter back-end for Hugo
https://ox-hugo.scripter.co
GNU General Public License v3.0
867 stars 130 forks source link

[FR] Option to export as index.md, even when EXPORT_FILE_NAME set to something else. #734

Open rwilson4 opened 5 months ago

rwilson4 commented 5 months ago

Hi folks, First off, thanks so much for creating ox-hugo. I've been using it with my blog recently, and loving it.

In my blogging flow, all posts get created as bundles, e.g. in content/post/<blog_title>/index.md. I can achieve this with ox-hugo by setting the EXPORT_HUGO_BUNDLE property to and EXPORT_FILE_NAME to index.

But I often want to export my post in multiple formats, not just Hugo. I often also export as a LaTeX doc. For that my EXPORT_FILE_NAME needs to be export/<blog_title>. Then when I export as pdf, it get saved as export/<blog_title>.pdf. But then when I export via ox-hugo, it gets saved as content/post/<blog_title>/<blog_title>.md, which isn't what I want. Hugo (or at least, the academic theme I use), doesn't seem to recognize anything other than index.md, so the file seemingly has to be index.md.

I have a kludgey work-around: I know enough elisp to have manually edited org-hugo-export-to-md to ignore EXPORT_FILE_NAME and just hard-code to index.md. I replaced the line: (outfile (org-export-output-file-name ".md" subtreep pub-dir)))

with: (outfile (concat (file-name-as-directory pub-dir) "index.md")))

And that seems to do it for me. But obviously not everyone wants to do that. So my request/suggestion is to enable the user to always export as index.md (perhaps only when EXPORT_HUGO_BUNDLE is specified), ignoring EXPORT_FILE_NAME.

Thanks again folks!