Problem
When using a keyword that is in the page title, "You're linking to another page with the focus keyword you want this page to rank for. Consider changing that if you truly want this page to rank." is always flagged.
I have debugged the "paper" variable in the JS, and it is adding the title as a link, because of this, from the node template:
{{ title_prefix }}
{% if label and not page %}
<h2{{ title_attributes }}>
<a href="{{ url }}" rel="bookmark">{{ label }}</a>
</h2>
{% endif %}
{{ title_suffix }}
However, the actual page does not render the title as a link, and the html snippet is not present in the DOM. I have tried with Stable9 and Olivero, and I am using the Default view mode.
I am not sure why this is happening, any suggestions would be appreciated. A possible indirect fix would be to ignore any links that reference the current page?
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 2025-03-11_18-50.png | 228.56 KB | solanas |
Issue fork yoast_seo-3503405
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3503405-youre-linking-to
changes, plain diff MR !40
Comments
Comment #2
solanas commentedSame problem here.
I'm on a new and clean Drupal 10.4.4. I only have installed yoast_seo 8.x-2.1.
I don't know how to debug this. May the problem is that this link is in the "Breadcrum".
Comment #3
drale01 commentedI’m experiencing the same issue — no matter what I do, it always shows “You're linking to another page with the focus keyword” as flagged.
Comment #6
borisr commentedI ran into the same issue and after some debugging I found that the modules sets the 'in_preview' flag to true for nodes. Setting the 'preview_view_mode' variable to the correct view mode seems to resolve the issue.
Comment #7
borisr commentedComment #8
borisr commentedI've done some more testing, and it seems that adding a link within the node also triggers the message "You're linking to another page with the focus keyword" regardless of the link content. This happens when the rendering theme wraps the node with an tag. Replacing the article tag fixes this issue.
I'm not sure if there are related/known issues, or if this is intentional.
Perhaps removing the article tag during rendering might solve it (although I'm not usually a fan of manipulating these kinds of things).
Comment #10
kingdutchThanks for the investigation and proposed fix borisr! I've added a line to test coverage to test for the bug and merged your fix.
Comment #12
borisr commented@kingdutch thanks! What are your thoughts on the issue with the tags? I'am not sure if the module should handle this but on the other side (or if this is actually working as intended) but most default templates are wrapping the node in an tag.
Comment #13
kingdutchLets spin that out to a separate issue. I'm not entirely sure what you mean by "article" tag, so I'd like to discuss that separately. Also because then we can write a more specialised test to demonstrate the issue :D
Comment #14
borisr commentedThat seems like a good idea. I just create a new issue (see https://www.drupal.org/project/yoast_seo/issues/3535659) where we can discuss this further and decide course of action.