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

meta generator in <body> when using hexo-nofollow plugin #3313

Closed
curbengh opened this issue Oct 26, 2018 · 1 comment · Fixed by #3315
Closed

meta generator in <body> when using hexo-nofollow plugin #3313

curbengh opened this issue Oct 26, 2018 · 1 comment · Fixed by #3315

Comments

@curbengh
Copy link
Contributor

curbengh commented Oct 26, 2018

I'm the author of hexo-nofollow plugin. After upgrading to v3.8.0, the meta generator (#3129) is added too many times (see curbengh/hexo-testing@f4824bb), instead of <head> only.

No issue if I disable the plugin, meta generator is only added once per page.

Environment Info

Node version(node -v): v10.12.0

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

$ npm ls --depth 0
[email protected] /home/blog/npm/hexo-testing
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]
$ hexo g --debug
DEBUG Writing database to hexo-testing/db.json
DEBUG Hexo version: 3.8.0
DEBUG Working directory: hexo-testing/
DEBUG Config loaded: hexo-testing/_config.yml
DEBUG Plugin loaded: hexo-generator-archive
DEBUG Plugin loaded: hexo-generator-category
DEBUG Plugin loaded: hexo-generator-index
DEBUG Plugin loaded: hexo-generator-tag
DEBUG Plugin loaded: hexo-nofollow
DEBUG Plugin loaded: hexo-renderer-ejs
DEBUG Plugin loaded: hexo-renderer-marked
DEBUG Plugin loaded: hexo-renderer-stylus
DEBUG Plugin loaded: hexo-server
DEBUG Loading database.
INFO  Start processing
DEBUG Theme config loaded.
DEBUG Processed: _config.yml
DEBUG Processed: source/css/donate.css
DEBUG Processed: source/css/source.css
DEBUG Processed: source/images/alipay.svg
DEBUG Processed: source/images/bitcoin.svg
DEBUG Processed: source/images/github.svg
DEBUG Processed: source/images/like.svg
DEBUG Processed: source/images/paypal.svg
DEBUG Processed: source/images/wechat.svg
DEBUG Processed: source/js/typing.js
DEBUG Processed: source/css/typing.css
DEBUG Processed: layout/archive.ejs
DEBUG Processed: layout/category.ejs
DEBUG Processed: layout/index.ejs
DEBUG Processed: layout/layout.ejs
DEBUG Processed: layout/page.ejs
DEBUG Processed: layout/post.ejs
DEBUG Processed: layout/tag.ejs
DEBUG Processed: _posts/fancybox-test.md
DEBUG Processed: languages/default.yml
DEBUG Processed: languages/en.yml
DEBUG Processed: languages/es.yml
DEBUG Processed: languages/fr.yml
DEBUG Processed: languages/nl.yml
DEBUG Processed: languages/no.yml
DEBUG Processed: languages/ru.yml
DEBUG Processed: languages/zh-CN.yml
DEBUG Processed: languages/zh-TW.yml
DEBUG Processed: _posts/hello-world.md
DEBUG Processed: layout/_partial/after-footer.ejs
DEBUG Processed: layout/_partial/archive-post.ejs
DEBUG Processed: layout/_partial/archive.ejs
DEBUG Processed: layout/_partial/article.ejs
DEBUG Processed: layout/_partial/baidu_tongji.ejs
DEBUG Processed: layout/_partial/footer.ejs
DEBUG Processed: layout/_partial/gauges-analytics.ejs
DEBUG Processed: layout/_partial/google-analytics.ejs
DEBUG Processed: layout/_partial/head.ejs
DEBUG Processed: layout/_partial/header.ejs
DEBUG Processed: layout/_partial/post/category.ejs
DEBUG Processed: layout/_partial/post/date.ejs
DEBUG Processed: layout/_partial/post/gallery.ejs
DEBUG Processed: layout/_partial/post/nav.ejs
DEBUG Processed: layout/_partial/post/tag.ejs
DEBUG Processed: layout/_partial/post/title.ejs
DEBUG Generator: page
DEBUG Generator: post
DEBUG Generator: archive
DEBUG Generator: category
DEBUG Generator: index
DEBUG Generator: tag
DEBUG Generator: asset
INFO  Files loaded in 317 ms
DEBUG Rendering post: 2018/10/06/fancybox-test/index.html
DEBUG Rendering post: 2018/10/05/hello-world/index.html
DEBUG Rendering archive: archives/index.html
DEBUG Rendering archive: archives/2018/index.html
DEBUG Rendering archive: archives/2018/10/index.html
DEBUG Rendering index: index.html
INFO  Generated: index.html
INFO  Generated: archives/index.html
INFO  Generated: images/alipay.svg
INFO  Generated: images/bitcoin.svg
INFO  Generated: images/github.svg
INFO  Generated: images/like.svg
INFO  Generated: images/paypal.svg
INFO  Generated: images/wechat.svg
INFO  Generated: archives/2018/10/index.html
INFO  Generated: archives/2018/index.html
INFO  Generated: css/donate.css
INFO  Generated: js/typing.js
INFO  Generated: css/source.css
INFO  Generated: 2018/10/06/fancybox-test/index.html
INFO  Generated: 2018/10/05/hello-world/index.html
INFO  Generated: css/typing.css
INFO  16 files generated in 589 ms
DEBUG Database saved
curbengh pushed a commit to curbengh/hexo-nofollow that referenced this issue Oct 27, 2018
@curbengh
Copy link
Contributor Author

curbengh commented Oct 27, 2018

In the meantime, I'm using a workaround to remove all meta generator in <body>
curbengh/hexo-nofollow@1db317b

Edit: Turns out that workaround also remove meta generator tag in <head>...

Edit: Might be related to cheeriojs/cheerio#1031

Edit: It is related. Here's what I think happened:

  1. When using cheerio 1.0.0-rc.1+, <html><head><body> are automatically added to every empty or open tag. If I have <p>, it will results in,
<html><head></head><body><p></body></html>
  1. meta_generator.js prepend meta generator tag to every <head>. e.g.
<html><head><meta name="generator"...></head><body><p></body></html>
  1. Those extra <html><head><body> are stripped away in $.html(), leaving
<meta name="generator"...><p>

As a workaround, meta_generator.js check content <head> and only prepend tag when it is not empty.

  if (!($('meta[name="generator"]').length > 0 ) && $('head').contents().length > 0) {
    $('head').prepend(hexoGeneratorTag.replace('%s', this.version));

    return $.html();
  }

curbengh pushed a commit to curbengh/hexo-nofollow that referenced this issue Oct 27, 2018
curbengh pushed a commit to curbengh/hexo that referenced this issue Oct 27, 2018
@curbengh curbengh changed the title Excessive meta generator when using hexo-nofollow plugin meta generator in <body> when using hexo-nofollow plugin Oct 27, 2018
yoshinorin added a commit that referenced this issue Oct 28, 2018
fix: compatibility with cheerio 1.0.0+ (#3313)
thom4parisot pushed a commit to thom4parisot/hexo that referenced this issue Jan 17, 2020
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

Successfully merging a pull request may close this issue.

1 participant