1

I’m using hexo to build a blog recently, but the posts generated by hexo -g have date of 1970:

(base) root@DESKTOP-7SU7LQD:/mnt/d/Blog_2# ls source/_posts/
hello-world.md
(base) root@DESKTOP-7SU7LQD:/mnt/d/Blog_2# hexo g
...
INFO  Generated: 1970/01/01/hello-world/index.html
INFO  37 files generated in 2.65 s
(base) root@DESKTOP-7SU7LQD:/mnt/d/Blog_2# ls public/
1970  404.html  about  archives  categories  css  img  index.html  js  lib  links  local-search.xml  tags  xml

How can I handle this problem ?

wutao
  • 54
  • 4

1 Answers1

1

Can you show a source file, a post?

Without further details, it's very likely a missing front matter It is not mandatory for "compilation" but it may cause issues later when files are processed from Markdown to Yaml to Html.

It will help to separate files

---
title: Hello World
date: 2013/7/13 20:46:25
---

Another solution would be to use https://hexo.io/docs/variables#Page-Variables : momentjs' date_updated page variable which seems to be more likely to the point enter link description here

You would need to use updated_option: 'date'

EDIT: 2nd solution

Alsushi
  • 373
  • 3
  • 14
  • Thank you for your answer. Yes, when I set the date in md file, It is normal. But according to the hexo ,when I don't set the date, the default is the time I created the md file (however I got 1970). Here is my source file (in google drive): https://drive.google.com/file/d/1sE-BWf4m5Lw9ARSYR_epOsZk0uBhg_yi/view?usp=sharing ; and I still have the same problem when I change another computer. – wutao May 25 '21 at 10:24
  • 1
    I have this behavior too when generating from md straight without front matter – Alsushi May 25 '21 at 11:51
  • 1
    Into the basic config for posts /hexo/scaffold/post.md You can see a "date" variable. So I think if you use the (assumed) most common workflow by using hexo-CLI, then, the date would be added. However by copy pasting files into `source ` folder, there won't be any date data added to text, unless main config can overwrite that, but so far I didn't find any config option to overwrite date... As a workaround you could prepend `title: {{ title }} date: {{ date }} ` EDIT: hexo is using moment.js for date, you would have to use `updated_option` – Alsushi May 25 '21 at 12:48