Netlify构建Hugo博客导致文章修改时间失效

用Netlify自动构建Hugo博客时,会导致文章最会更新时间全部变成最后构建时间,(本地渲染时是发现不了这样的问题的)这样也失去了Lastmod的意义。 下面给出解决办法: 修改根目录下的netlify.toml代码。 修改前: [build] command = "hugo --gc --minify" publish = "public" 修改为: [build] command = '''find content/posts -name '*.md' | while read file; do touch -d "$(git log -1 --format="@%ct" "$file")" "$file"; done; hugo --gc --minify''' publish = "public" 若只修改posts文件夹内的文章,按上述代码即可,若content内有多个文章文件夹,或自己配置的其他文件夹,可使用下面代码: ...

2021年8月10日 · 1 分钟 · Chow Ray · PGP SIGNED