From 56d7e4f6426b4df5cf8a55a811430c9a5e3c79f4 Mon Sep 17 00:00:00 2001 From: PeninsulaInd Date: Sat, 20 Dec 2025 10:01:38 -0600 Subject: [PATCH] Fix explicit anchor text to randomize term selection Randomize anchor text list before trying terms so all explicit terms are used across articles instead of always using the first term. --- src/interlinking/content_injection.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/interlinking/content_injection.py b/src/interlinking/content_injection.py index 48d2c69..9d43e93 100644 --- a/src/interlinking/content_injection.py +++ b/src/interlinking/content_injection.py @@ -336,6 +336,10 @@ def _try_inject_link(html: str, anchor_texts: List[str], target_url: str) -> Tup Try to inject a link with anchor text into HTML Returns (updated_html, link_injected, anchor_text_used) """ + # Randomize order to use different terms across articles + if anchor_texts and len(anchor_texts) > 1: + anchor_texts = random.sample(anchor_texts, len(anchor_texts)) + for anchor_text in anchor_texts: # Try to find and wrap anchor text in content updated_html, found = _find_and_wrap_anchor_text(html, anchor_text, target_url)