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?

CommentFileSizeAuthor
#2 2025-03-11_18-50.png228.56 KBsolanas

Issue fork yoast_seo-3503405

Command icon 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:

Comments

scambler created an issue. See original summary.

solanas’s picture

StatusFileSize
new228.56 KB

Same 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".

screenshot with problem

drale01’s picture

I’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.

borisr made their first commit to this issue’s fork.

borisr’s picture

I 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.

borisr’s picture

Status: Active » Needs review
borisr’s picture

I'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).

  • kingdutch committed 05c257b6 on 8.x-2.x
    Issue #3503405 by borisr, solanas, scambler, drale01: 'You're linking to...
kingdutch’s picture

Version: 8.x-2.1 » 8.x-2.x-dev
Status: Needs review » Fixed

Thanks for the investigation and proposed fix borisr! I've added a line to test coverage to test for the bug and merged your fix.

borisr’s picture

@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.

kingdutch’s picture

Lets 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

borisr’s picture

That 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.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.