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)