【问题标题】:Why the date of the file generated by hexo is 1970为什么hexo生成的文件日期是1970
【发布时间】:2021-05-16 08:29:41
【问题描述】:

我最近在用hexo建博客,但是hexo -g生成的帖子都是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

我该如何处理这个问题?

【问题讨论】:

    标签: time hexo


    【解决方案1】:

    你能显示一个源文件,一个帖子吗?

    如果没有更多细节,很可能是缺少front matter “编译”不是强制性的,但在文件从 Markdown 处理到 Yaml 到 Html 时可能会导致问题。

    这将有助于分离文件

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

    另一种解决方案是使用https://hexo.io/docs/variables#Page-Variables:momentjs' date_updated 页面变量 这似乎更有可能 enter link description here

    您需要使用updated_option: 'date'

    编辑:第二个解决方案

    【讨论】:

    • 感谢您的回答。是的,当我在 md 文件中设置日期时,这是正常的。但是根据 hexo ,当我不设置日期时,默认是我创建 md 文件的时间(但是我得到的是 1970 年)。这是我的源文件(在谷歌驱动器中):drive.google.com/file/d/1sE-BWf4m5Lw9ARSYR_epOsZk0uBhg_yi/…;当我换了另一台电脑时,我仍然遇到同样的问题。
    • 从 md 直接生成时我也有这种行为
    • 进入帖子的基本配置 /hexo/scaffold/post.md 你可以看到一个“日期”变量。因此,我认为如果您通过使用 hexo-CLI 使用(假设的)最常见的工作流程,那么将添加日期。但是,通过将粘贴文件复制到source 文件夹中,不会有任何日期数据添加到文本中,除非主配置可以覆盖它,但到目前为止我没有找到任何配置选项来覆盖日期......作为一种解决方法你可以在前面加上title: {{ title }} date: {{ date }} 编辑:hexo 使用moment.js 作为日期,你必须使用updated_option
    猜你喜欢
    • 1970-01-01
    • 2020-07-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-24
    • 2011-07-02
    相关资源
    最近更新 更多