Skip to content

When publishing a draft, all the front-matter configuration is overwritten to defaults #5155

@neverbot

Description

@neverbot

Check List

Please check followings before submitting a new issue.

Expected behavior

When publishing a draft, if the draft have some front-matter configuration specified, the published post should keep it. Or at least it will make more sense to me. Maybe not the date, I guess.

Actual behavior

When publishing a draft, all the front-matter post configuration is overwritten to defaults. i.e. tags/categories are removed and only the default ones are set.

How to reproduce?

$ npx hexo new draft "Test"
INFO  Validating config
INFO  Created: ~/something/something/source/_drafts/test.md

$ ls -lah source/_drafts/test*
-rw-r--r--   1 something  something    72B Feb  3 12:47 source/_drafts/test.md

source/_drafts/test:
total 0
drwxr-xr-x   2 something  something    64B Feb  3 12:47 .
drwxr-xr-x  11 something  something   352B Feb  3 12:47 ..

The created draft should have the defaults, in my case:

---
title: Test
tags:
  - blog
author: something
---

Edit it, modifying tags:

---
title: Test
tags:
  - a
  - b
author: something
---

Publish it:

$ npx hexo publish test
INFO  Validating config
INFO  Published: ~/something/something/source/_posts/2023/02/03/test.md

The published post has the default values again (content of the post is ok, of course):

---
title: Test
tags:
  - blog
author: something
date: 2023-02-03 12:49:38
---

Is the problem still there under "Safe mode"?

Yes.

Environment & Settings

Node.js & npm version(node -v && npm -v)

$ node -v && npm -v
v16.17.1
8.15.0

Hexo and Plugin version(npm ls --depth 0)

hexo-site@0.0.0 /something/something
├── hexo-asset-link@2.2.1
├── hexo-fontawesome@2.3.0
├── hexo-generator-archive@2.0.0
├── hexo-generator-category@2.0.0
├── hexo-generator-feed@3.0.0
├── hexo-generator-index@3.0.0
├── hexo-generator-tag@2.0.0
├── hexo-migrator-wordpress@2.1.2
├── hexo-renderer-ejs@2.0.0
├── hexo-renderer-markdown@1.6.0
├── hexo-renderer-stylus@2.1.0
├── hexo-server@3.0.0
├── hexo-statistics-charts@3.3.1
├── hexo-tag-instagram@1.1.0
├── hexo-theme-landscape@0.0.3
└── hexo@6.3.0

Others

$ npx hexo version
INFO  Validating config
hexo: 6.3.0
hexo-cli: 4.3.0
os: darwin 22.1.0 13.0.1

node: 16.17.1
v8: 9.4.146.26-node.22
uv: 1.43.0
zlib: 1.2.11
brotli: 1.0.9
ares: 1.18.1
modules: 93
nghttp2: 1.47.0
napi: 8
llhttp: 6.0.9
openssl: 1.1.1q+quic
cldr: 41.0
icu: 71.1
tz: 2022a
unicode: 14.0
ngtcp2: 0.1.0-DEV
nghttp3: 0.1.0-DEV

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions