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

fix(open_graph): remove duplicate twitter card tags #3668

Merged
merged 3 commits into from
Aug 22, 2019

Conversation

SukkaW
Copy link
Member

@SukkaW SukkaW commented Aug 15, 2019

What does it do?

Remove twitter:title and twitter:description which is duplicated with og:title and og:description

According to the Twitter Card Docs:

When using Open Graph protocol to describe data on a page, it is easy to generate a Twitter card without duplicating tags and data. When the Twitter card processor looks for tags on a page, it first checks for the Twitter-specific property, and if not present, falls back to the supported Open Graph property.

SInce the value of twitter:title and twitter:description is the same as og:title and og:description, they can be removed.

How to test

git clone -b BRANCH https://github.com/USER/hexo.git
cd hexo
npm install
npm test

Pull request tasks

  • Add test cases for the changes.
  • Passed the CI test.

@coveralls
Copy link

coveralls commented Aug 15, 2019

Coverage Status

Coverage decreased (-0.002%) to 97.152% when pulling 65757c9 on SukkaW:remove-duplicate-og-tag into 3176fe0 on hexojs:master.

@curbengh
Copy link
Contributor

please remove relevant lines in "test/scripts/helpers/open_graph.js".

test/scripts/helpers/open_graph.js Outdated Show resolved Hide resolved
@curbengh curbengh changed the title fix: remove duplicated twitter card tags fix(open_graph): remove duplicate twitter card tags Aug 17, 2019
result += meta('twitter:title', title);
if (description) {
result += meta('twitter:description', description, false);
}

if (images.length) {
result += meta('twitter:image', images[0], false);
Copy link
Member

@yoshinorin yoshinorin Aug 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

twitter:image is deletable. Isn't it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yoshinorin It seems like og:image support multiple images while twitter:image only support one image. The docs from twitter do not mention multiple images usage.

Copy link
Contributor

@curbengh curbengh Aug 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The doc is not exactly clear.

URL of image to use in the card. Images must be less than 5MB in size. JPG, PNG, WEBP and GIF formats are supported. Only the first frame of an animated GIF will be used. SVG is not supported.

"URL of image....Images must..."; image? images?

Anyway, the doc does mention twitter:image fallback to og:image, so I think it's redundant too.

Copy link
Member

@yoshinorin yoshinorin Aug 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SukkaW @curbengh

I found following comments from twitter developers forum.

According to comments. The twitter card use last og:image if multiple og:image tags exists. It's not following ogp specification.

They are very old comments (4~6 years ago). I could not find newer information. IMHO we should use twitter:image if we can not find more information about this matter.

I will merge this if other opinion does not exist after wait a while.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to comments. The twitter card use last og:image if multiple og:image tags exists. It's not following ogp specification.

I figure most users would expect the first image, which is the current behavior of open_graph.js. Let's keep twitter:image for now.

@yoshinorin yoshinorin merged commit b402da0 into hexojs:master Aug 22, 2019
@yoshinorin yoshinorin added this to the v4.0.0 milestone Aug 22, 2019
thom4parisot pushed a commit to thom4parisot/hexo that referenced this pull request Jan 17, 2020
* fix: remove duplicated twitter card tags

* test(open_graph): add og:locale & remove twitter:title

* test(open_graph): remove twitter:description & update item
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 this pull request may close these issues.

4 participants