Skip to content

plugin issue: Tags removed by setTags in before_post_render filter still exists in the tag list but the page is not generated #5380

@SineObama

Description

@SineObama

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

I need to change the posts' tags with my own filter. I find out the setTags method when using hexo 6.3.0 and it always works before I upgrade to hexo 7.0.

This is an example code:

hexo.extend.filter.register('before_post_render', function (data) {
    if (!data.tags || !data.categories) {
        return data;
    }

    data.setTags([]);

    return data;
});

In this case, some of the tags are removed completely from my website. I expect those tags to disappear.

I test this problem in my repo branch.

Actual behavior

The tag list remain the removed tags and I can not jump into the tag's page(the page was not generated).

How to reproduce?

simply a post with tag and run with the example filter code above (using the setTags method to remove tag(s) in before_post_render filter).

Is the problem still there under Safe mode?

this is a plugin usage problem, and I disabled my theme and my other plugins, I just using the example code, the problem still there.

Your Node.js & npm version

v18.18.0
10.2.4

Your Hexo and Plugin version

hexo-site@0.0.0 D:\workspace\hexoProject\blog
+-- hexo-filter-nofollow@2.0.2
+-- 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-search@2.4.3
+-- hexo-generator-sitemap@3.0.1
+-- hexo-generator-tag@2.0.0
+-- hexo-renderer-ejs@2.0.0
+-- hexo-renderer-marked@6.2.0
+-- hexo-renderer-pug@3.0.0
+-- hexo-renderer-stylus@3.0.0
+-- hexo-server@3.0.0
+-- hexo-theme-butterfly@4.11.0
+-- hexo-theme-landscape@1.0.0
+-- hexo-wordcount@6.0.1
`-- hexo@7.0.0

Your package.json

{
  "name": "hexo-site",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "build": "hexo generate",
    "clean": "hexo clean",
    "deploy": "hexo deploy",
    "server": "hexo server"
  },
  "hexo": {
    "version": "7.0.0"
  },
  "dependencies": {
    "hexo": "^7.0.0",
    "hexo-filter-nofollow": "^2.0.2",
    "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-search": "^2.4.3",
    "hexo-generator-sitemap": "^3.0.1",
    "hexo-generator-tag": "^2.0.0",
    "hexo-renderer-ejs": "^2.0.0",
    "hexo-renderer-marked": "^6.2.0",
    "hexo-renderer-pug": "^3.0.0",
    "hexo-renderer-stylus": "^3.0.0",
    "hexo-server": "^3.0.0",
    "hexo-theme-butterfly": "^4.11.0",
    "hexo-theme-landscape": "^1.0.0",
    "hexo-wordcount": "^6.0.1"
  }
}

Others

No response

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