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

Truncate the description value to 100 words #492

Merged
merged 3 commits into from
Nov 6, 2023

Conversation

kemenaran
Copy link
Contributor

@kemenaran kemenaran commented Jun 30, 2023

Currently, on post pages, the value of the description, og: description, twitter: description and application/ld-json tags represent the whole text of the post.

Which means that the text of the post is included five times in the HTML document – adding to the page weight needlessly.

This commit ensures the description string is truncated to a sane value.

Currently the value of the `description`, `og: description`
and `twitter: description` tags includes the whole text of the post.

Which means that, on post pages, the text of the post is included *four*
times in the HTML document – adding to the page weight needlessly.

This commit ensures the description string is truncated to a sane value.
@y377
Copy link
Member

y377 commented Aug 18, 2023

@kemenaran If it can be customized according to the percentage, this should be the ultimate solution: for example, from 10% to 90% of the full text (if the description is defined in the preface), it is recommended to consider it!

@kemenaran
Copy link
Contributor Author

@mattr- would you consider this improvement mergeable in the current state – or do you prefer to make it configurable?

@mattr-
Copy link
Member

mattr- commented Aug 31, 2023

280 characters feels like a twitter specific limitation. Regardless of that, a blanket truncation at 280 characters doesn't take into account word or sentence endings, and it feels like we should do that before this PR is mergeable.

@kemenaran
Copy link
Contributor Author

@mattr- thanks for your review! I updated the PR to:

  • Limit the description length based on words count (instead of characters count);
  • Make the maximum word count configurable (per page or site-wide).

I also added tests, and a new documentation section describing the behavior.

Does that look reasonable to you?

Copy link
Member

@mattr- mattr- left a comment

Choose a reason for hiding this comment

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

Thanks for updating this! Everything here looks good to me!

Copy link
Member

@mattr- mattr- left a comment

Choose a reason for hiding this comment

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

Looks like the code style check came up with a few things to fix. Would you mind addressing those?

@kemenaran kemenaran changed the title Truncate the description value to 280 chars Truncate the description value to 100 words Oct 31, 2023
@kemenaran
Copy link
Contributor Author

Yup, I just pushed fixes to the rubocop issues, it should be good now.

@mattr-
Copy link
Member

mattr- commented Nov 6, 2023

Thanks for tackling this!

@jekyllbot: merge +minor

@jekyllbot jekyllbot merged commit 589feb0 into jekyll:master Nov 6, 2023
8 checks passed
jekyllbot added a commit that referenced this pull request Nov 6, 2023
@kemenaran kemenaran deleted the truncate-description-value branch November 7, 2023 09:12
@kemenaran
Copy link
Contributor Author

Great! Thanks for having a look into this, and for the maintenance work.

@y377
Copy link
Member

y377 commented Nov 22, 2023

@jekyllbot @kemenaran
Thank you for your great efforts. Please tell me how to update the improved code. Because the plug-in has been installed before, no matter whether you use gem install jekyll-seo-tag or gem update jekyll-seo-tag, it will not help.

@mattr-
Copy link
Member

mattr- commented Nov 22, 2023

You'll need to wait on a plugin release or tell bundler to fetch the code from the git repo in order to use this new feature.

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

Successfully merging this pull request may close these issues.

4 participants