Automattic / Automattic/wp-calypso
Canonical URL Being Set to Comment URL when comments are set to break into pages and content contains comments
- Dominant language
- TypeScript
- Stars
- 12.6k
- Forks
- 2k
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 552
Description
_Slight updates added to the report after [triaging](https://github.com/Automattic/wp-calypso/issues/76589#issuecomment-1535453995) -cuemarie_
### Quick summary
On certain themes like Blank Canvas, Attar, and Twenty Twenty-three, _when Settings > Discussion is set to "Break comments into pages", and a page or post contains at least one comment,_ the canonical URL is set to the comment URL of the page instead of the actual URL of the page.
~This was first reported on an FSE theme. However, it does not happen on all FSE themes, as Twenty Twenty-Two works fine. I tested a few Classic themes (Twenty Nineteen & Hemingway Rewritten), and they were fine, but I can't tell if it happens on other classic themes.~
_With the updated step of enabling "Break comments into pages", I was able to replicate in both TT2 and Twenty Nineteen, so I don't think at this time this is theme specific. -cuemarie_
### Steps to reproduce
1. Switch to the Blank Canvas theme.
2. Add a comment on the page.
3. _Open Settings > Discussion and enable the setting "Break comments into pages..."_
4. View the page source and search for "canonical."
5. The canonical URL is set as the comment URL.
the
### What you expected to happen
The canonical URL to be set as the default URL of the page

### What actually happened
The issue was first reported in 6258023-zen. A user run an SEO report on SEMRush and they were told that some URLs that are listed in my sitemaps that are "non-canonical" and, therefore may confuse the search engines. I inspected those URLs and found that they were all comment URLs.
### Impact
Most (> 50%)
### Available workarounds?
Yes, easy to implement
### Platform (Simple and/or Atomic)
Simple, Atomic
### Logs or notes
Workarounds include **_Deactivating the "Break comments into pages setting_**, switching themes, removing comments, or using an SEO plugin to set a canonical URL. However, some of these workarounds may be inconvenient for users.
Contributor guide
Research direction
Reproduce the issue with a page containing a comment and Settings > Discussion set to “Break comments into pages,” then inspect the page source for the canonical URL. Trace where the canonical URL is generated and verify that it uses the page URL rather than the comment URL across the reported themes and platforms.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- wordpress
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100