Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Having a path in config.new_post_name breaks tag plugin post_link #5361

Closed
5 tasks done
kristofzerbe opened this issue Nov 23, 2023 · 4 comments
Closed
5 tasks done

Comments

@kristofzerbe
Copy link
Contributor

Check List

  • I have already read Docs page & Troubleshooting page.
  • I have already searched existing issues and they are not help to me.
  • I examined error or warning messages and it's difficult to solve.
  • I am using the latest version of Hexo. (run hexo version to check)
  • My Node.js is matched the required version.

Expected behavior

My post folder structure relies on subfolders per year, like _posts/2023/my-fancy-post.md, with asset folders of the same name, and I use the Tag Plugin post_link in many posts.

Since hexo new post XXX always creates the new post in the root post folder, I recently changed the config entry new_post_name from :title.md to :year/:title to create the new posts directly in the correct folder.

I expected that the new post is created in the appropriate subfolder (works) and Hexo generates my files (works not)

Actual behavior

After the change my build, which executes hexo clean && hexo generate, aborts with the following message:

Template render error: (unknown path)
  Error: Post not found: post_link 2023/My-fancy-post.
    at Object._prettifyError (C:\Projects\kiko.io\node_modules\nunjucks\src\lib.js:36:11)
    at C:\Projects\kiko.io\node_modules\nunjucks\src\environment.js:563:19
    at Template.root [as rootRenderFunc] (eval at _compile (C:\Projects\kiko.io\node_modules\nunjucks\src\environment.js:633:18), <anonymous>:92:3)
    at Template.render (C:\Projects\kiko.io\node_modules\nunjucks\src\environment.js:552:10)
    at Environment.renderString (C:\Projects\kiko.io\node_modules\nunjucks\src\environment.js:380:17)
    at C:\Projects\kiko.io\node_modules\hexo\dist\extend\tag.js:206:22
    at tryCatcher (C:\Projects\kiko.io\node_modules\hexo\node_modules\bluebird\js\release\util.js:16:23)
    at Function.Promise.fromNode.Promise.fromCallback (C:\Projects\kiko.io\node_modules\hexo\node_modules\bluebird\js\release\promise.js:209:30)
    at Tag.render (C:\Projects\kiko.io\node_modules\hexo\dist\extend\tag.js:205:35)
    at Object.onRenderEnd (C:\Projects\kiko.io\node_modules\hexo\dist\hexo\post.js:399:32)
    at C:\Projects\kiko.io\node_modules\hexo\dist\hexo\render.js:77:29
    at tryCatcher (C:\Projects\kiko.io\node_modules\hexo\node_modules\bluebird\js\release\util.js:16:23)
    at Promise._settlePromiseFromHandler (C:\Projects\kiko.io\node_modules\hexo\node_modules\bluebird\js\release\promise.js:547:31)
    at Promise._settlePromise (C:\Projects\kiko.io\node_modules\hexo\node_modules\bluebird\js\release\promise.js:604:18)
    at Promise._settlePromise0 (C:\Projects\kiko.io\node_modules\hexo\node_modules\bluebird\js\release\promise.js:649:10)
    at Promise._settlePromises (C:\Projects\kiko.io\node_modules\hexo\node_modules\bluebird\js\release\promise.js:729:18)
    at _drainQueueStep (C:\Projects\kiko.io\node_modules\hexo\node_modules\bluebird\js\release\async.js:93:12)
    at _drainQueue (C:\Projects\kiko.io\node_modules\hexo\node_modules\bluebird\js\release\async.js:86:9)
    at Async._drainQueues (C:\Projects\kiko.io\node_modules\hexo\node_modules\bluebird\js\release\async.js:102:5)
    at Immediate.Async.drainQueues (C:\Projects\kiko.io\node_modules\hexo\node_modules\bluebird\js\release\async.js:15:14)
    at processImmediate (internal/timers.js:464:21)

The error occurs comprehensible in Hexo 6.3.0 as well as in 7.0.0. :title = generation works, :year/:title generation stops with error.

How to reproduce?

  1. Clone https://github.com/kristofzerbe/kiko.io
  2. Edit /_config.yml with new_post_name: :year/:title.md
  3. Run hexo generate

Is the problem still there under Safe mode?

Yes

Your Node.js & npm version

Node: v14.17.2
NPM: 6.14.13

Your Hexo and Plugin version

+-- hexo@7.0.0
+-- hexo-asset-link@2.2.2
+-- hexo-browsersync@0.3.0
+-- hexo-cli@4.3.1
+-- hexo-front-matter@4.2.1
+-- hexo-fs@4.1.1
+-- hexo-generator-alias@1.0.0
+-- hexo-generator-anything@1.0.12
+-- hexo-generator-archive@2.0.0
+-- hexo-generator-category@2.0.0
+-- hexo-generator-copy@0.1.0
+-- hexo-generator-index@3.0.0
+-- hexo-generator-json-content@4.2.3
+-- hexo-generator-sitemap@3.0.1
+-- hexo-generator-tag@2.0.0
+-- hexo-hide-posts@0.4.0
+-- hexo-renderer-ejs@2.0.0
+-- hexo-renderer-marked@6.1.1
+-- hexo-renderer-stylus@3.0.0
+-- hexo-server@3.0.0
+-- hexo-tag-video@0.0.2

Your package.json

see https://github.com/kristofzerbe/kiko.io/blob/master/package.json

Your site's _config.yml (Optional)

see https://github.com/kristofzerbe/kiko.io/blob/master/_config.yml

Others

I was hoping issues like #5042 would help me, but that wasn't the case

@kristofzerbe
Copy link
Contributor Author

same with #4778

@kristofzerbe
Copy link
Contributor Author

kristofzerbe commented Nov 23, 2023

One more thing, I didn't mentioned: The post_link's in my MD's are looking always like this:

{% post_link 2023/My-fancy-post %}

... as Steven pointed out in #5042 (comment)

@D-Sketon
Copy link
Member

It seems that if you change the config entry new_post_name from :title.md to :year/:title.md, you need to remove the subfolder prefix in post_link like {% post_link My-fancy-post %}

@kristofzerbe
Copy link
Contributor Author

Oh yes, you're right. Works, even if I couldn't directly establish a connection between the config entry and the tag in my head and in the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants