Hugo fails to parse date from an Emacs Org-mode LaTeX date


#1

Hi

I am testing different ways to blog with org-mode. Now I use Jekyll (https://blog.infotics.es) and I am searching for native support for orgmode.

Hugo says it supports “Emacs orgmode syntax”. That’s pretty cool but I have found out something weird: Hugo fails to parse date string set in the LaTeX headers I use.

I would like to post with Emacs + orgmode + LaTeX. I’ve been reading about ox-hugo and it works nice but I wouldn’t like to export to Markdown Blackfriday.

After googling for a while nothing seems to fix my problem.

Just in case you don’t know what I am talking about, this is a LaTeX header:

#+DATE: [2016-09-01 jue 16:00]

And this is the message I get:

ERROR 2018/01/06 20:35:27 Failed to parse date '[2016-09-01 jue 16:00]' in page post/2016-09-01-test.org

If you know how to do it I would appreciate it.

Thanks in advance!


#2

Thanks! I am the ox-hugo developer. Would love to get feedback if you ever end up using it.

Out of curiosity, what’s the reason for that?

You can choose to export Org to Markdown using ox-hugo and commit the Markdown files, or do the ox-hugo export + run Hugo in tandem on CI (i.e. commit only the Org files). I use the latter approach for the https://ox-hugo.scripter.co and the official use-package doc site generation.

Goorgeous expects the date to be already in TOML compatible date string format… few examples:

  • 2017-07-31
  • 2017-07-31T17:05:38
  • 2017-07-31T17:05:38Z
  • 2017-07-31T17:05:38+04:00
  • 2017-07-31T17:05:38-04:00

Reference: https://tools.ietf.org/html/rfc3339#section-5.8

You’d need real Org to parse that default Org date stamp format to a time format (which ox-hugo does).


I also have this ever-growing test Org file with 200+ actual Org syntax tests that make up for most of the ox-hugo test site content.


#3

Hi kaushalmodi, great to hear from you :slight_smile:

Out of curiosity, what’s the reason for that?

I would like to keep my org-files as they are written because:

  • It is harder to manage different versions of documents
  • Although I like very much your project and I am still testing it, I’d like some tool able to manage native org-mode files with LaTeX headers as they are written.

Before testing your extension I was excited with the feature to use Emacs orgmode file so I have already inserted HUGO headers in the org files I’ve been playing with. If I have to do that for all of them it is another extra task.

You can choose to export Org to Markdown using ox-hugo and commit the Markdown files, or do the ox-hugo export + run Hugo in tandem on CI (i.e. commit only the Org files). I use the latter approach for the https://ox-hugo.scripter.co and the official use-package doc site generation.

I have chosen the option auto-export-on-saving (one post per file) and it works, but I also get other errors regarding timeset and configuration… I have to take a look again to some files I changed.

Reference: https://tools.ietf.org/html/rfc3339#section-5.8

After searching for LaTeX 3339 I have realized is orgmode which stamps time in that format, so maybe if I get that (orgmode timestamp in RFC 3339) it is possible to use as they are written in orgmode.

Thanks for your feedback!


#4

Well, that was my primary aim to write the ox-hugo package… though, “keep the Org files as they are” is more effective with per-subtree export option (example). For per-file export option, you do need to manually specify tags, etc (example).

I’d appreciate if you can open an issue on ox-hugo repo and post an example file of yours. I don’t exactly follow what you mean by “LaTeX headers”… The #+DATE example you posted earlier is an Org keyword, which is parsed by all Org exporters (including ox-latex, and even ox-hugo).

As I mentioned earlier, unfortunately that’s the only way if you choose per-file export. If you organize your files as subtrees in a single Org file, most of the meta data required for Hugo front-matter is auto-interpreted as explained in the first table here. Re-organizing your files into subtrees would also be an extra task, but it would be a one-time thing. If you are mildly interested in the per-subtree export flow, see this recent test commit to ox-hugo that shows how a subtree added to the tests Org file exports to a Hugo markdown post.

I’d appreciate if you can open an issue on ox-hugo repo with your sample file and steps to reproduce those errors.

Correct. That time stamp format has nothing to do with LaTeX… and thus I talk about clarifying what you mean by “LaTeX headers”.

Yes. You can customize the time stamp format to anything to like… see C-h v org-time-stamp-formats… change the cdr of that variable… eventually it is Emacs! :slight_smile:

If the date stamp is the only thing that hinders your blogging flow, then may be you don’t need ox-hugo, but even then please file issues for the errors you are seeing.

Thanks!


#5

No matter what I was doing I am now pretty happy with the ox-hugo all-posts version as you can see at infotics.es, best!