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

Character counter counts ampersands as 4 characters #951

Closed
wpsmort opened this issue Jul 7, 2017 · 10 comments

Comments

Projects
None yet
3 participants
@wpsmort
Copy link
Member

commented Jul 7, 2017

Reported here - https://wordpress.org/support/topic/meta-description-gets-cut-short/

I tested with the same description and whilst the description is only 151 characters, we seem to be treating it as longer. I believe this is because we're counting the & sign as four characters, i.e. &amp

@wpsmort wpsmort self-assigned this Jul 7, 2017

@wpsmort

This comment has been minimized.

Copy link
Member Author

commented Jul 7, 2017

I tested and found that the & sign is actually treated as 4 characters &amp. I've changed the title and description for this issue to reflect this.

@wpsmort wpsmort changed the title Character counter counts ampersands as 5 characters Character counter counts ampersands as 4 characters Jul 7, 2017

@wpsmort

This comment has been minimized.

Copy link
Member Author

commented Jul 28, 2017

I noticed today whilst testing with AIOSEOP v2.3.14.2 that apostrophes in the Site Title are being counted as 6 characters in autogenerated titles. For example, if you set your Site Title in WordPress to Steve's Site, the autogenerated title on the Edit Post screen shows 20 characters even though "Steve's Site" is only 12 characters. This is because it's counting the apostrophe as 6 characters for '

screen shot 2017-07-28 at 6 46 39 pm

@amostajo

This comment has been minimized.

Copy link
Contributor

commented Jul 28, 2017

I am not a SEO savvy, but I have a question here, do the character count affect SEO in some sort of way or is it just to make sure that the text will display well on search engine results?

Because if it does matter, then it should be counted right?

As much as I know, the count is just to make sure snippets look clean, they have not much influence when indexing on Google, if this is right then yes, the count should be altered so it does not count all charactes in html entities codes.
https://stackoverflow.com/questions/891977/do-html-entities-in-meta-tags-influence-indexing

What are your thoughs @wpsmort @michaeltorbert ?

@wpsmort

This comment has been minimized.

Copy link
Member Author

commented Jul 29, 2017

@amostajo The character count is to ensure a clean snippet in SERPs that does not exceed the number of characters allowed, resulting in an ellipses cutting off the title or description. If Google counts an ampersand or apostrophe as a single character then we should too.

@amostajo amostajo self-assigned this Aug 3, 2017

@amostajo

This comment has been minimized.

Copy link
Contributor

commented Aug 3, 2017

@wpsmort So this only happens for auto-generated?

@wpsmort

This comment has been minimized.

Copy link
Member Author

commented Aug 3, 2017

@amostajo Yes, it only happens with the auto generated titles. The easiest way to test this is to set your Site Title to abc' and then leave your post title empty. The character count for the title should show 12 which breaks down as:

3 for the space | space
3 for the abc
6 for the '

You can do the same with the ampersand to get a count of 11 (5 for the &)

@wpsmort wpsmort added this to the 2.3.15 milestone Aug 3, 2017

@wpsmort wpsmort removed their assignment Aug 3, 2017

@wpsmort wpsmort removed the Needs Testing label Aug 3, 2017

@wpsmort wpsmort modified the milestones: 2.3.15, 2.3.16 Aug 3, 2017

amostajo added a commit to amostajo/all-in-one-seo-pack that referenced this issue Aug 3, 2017

semperfiwebdesign#951 Fixes wrong string counts due to HTML entities
Fixes wrong title/description length counts that were being generated
due to HTML entities not being decoded.
@amostajo

This comment has been minimized.

Copy link
Contributor

commented Aug 3, 2017

Ready for testing.

@wpsmort

This comment has been minimized.

Copy link
Member Author

commented Aug 14, 2017

@amostajo I've tested this and found one problem:

If you enable the Use Content For Autogenerated Descriptions and the content includes an ampersand then the meta description is shortened. It is not shortened if you disable that option.

The content I'm using is below which is exactly 160 characters but it gets shortened to 150 characters in my meta description:

C&23456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789

@wpsmort wpsmort modified the milestones: 2.3.16, 2.3.17 Aug 22, 2017

@wpsmort wpsmort modified the milestones: 2.3.17, 2.3.16 Aug 22, 2017

amostajo added a commit to amostajo/all-in-one-seo-pack that referenced this issue Aug 23, 2017

semperfiwebdesign#951 Refactored truncation execution order
Refactored the way the description was being truncated or cropped.
@amostajo

This comment has been minimized.

Copy link
Contributor

commented Aug 23, 2017

@wpsmort Ready for testing

@wpsmort

This comment has been minimized.

Copy link
Member Author

commented Sep 5, 2017

PR #1031 is tested and is good.

I have tested with Ampersands and Apostrophes in the post title, post excerpt, post content and site title.

@wpsmort wpsmort removed the Needs Testing label Sep 5, 2017

@wpsmort wpsmort assigned michaeltorbert and unassigned wpsmort Sep 5, 2017

@michaeltorbert michaeltorbert removed their assignment Sep 6, 2017

michaeltorbert added a commit that referenced this issue Sep 6, 2017

#951 Fixes wrong string counts due to HTML entities and #1022 never s…
…horten long description

#951 Fixes wrong string counts due to HTML entities and #1022 never shorten long description

* remove category capitalization from get_tax_name function #530

* remove tag and search capitalization of titles #560

* #951 Fixes wrong string counts due to HTML entities

Fixes wrong title/description length counts that were being generated
due to HTML entities not being decoded.
#951 Fixes wrong string counts due to HTML entities and #1022 never shorten long description

* #951 Refactored truncation execution order

Refactored the way the description was being truncated or cropped.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.