站内文章互链 + 锚文本策略 V1.0 · 总指挥出品

SEO科普 更新时间:2026-08-19 09:16:42

站内文章互链 + 锚文本策略 V1.0 · 总指挥出品

> 作者:总指挥(优优在手)

> 完成时间:2026-08-07 10:42

> 用途:wanshifwuyou.com KB 125 篇文章自动互链 + 锚文本 SEO 优化

> 关联文档:SEO 优化方案 / 首页改版规划 / 排盘结果页 wireframe

> 优先级:P0(SEO 7 天清单第 4 项)

---

一、互链策略总览

1.1 为什么需要互链

| 优势 | 说明 |

|---|---|

| SEO 权重流转 | 内链传递 PageRank,125 篇 KB 互相导权重 |

| 降低跳出率 | 用户读完一篇 → 推荐相关 → 停留更久 |

| 提升收录 | 爬虫沿内链发现所有页面 |

| 用户体验 | "想了解戊土日主?" 立即跳转详解 |

1.2 互链架构

`

首页(首页改版:板块 5 热门文章)

↓ 内链

文章列表页(/articles.html)

↓ 分类 + 标签

文章详情页(/articles.html?open=XXX)

↓ 相关推荐(互链)

相关文章(同分类 / 同标签 / 算法关联)

↓ CTA

排盘结果页(/result.html)→ 文章(钩子句)

`

---

二、互链锚文本策略

2.1 锚文本三原则

1. 自然嵌入:锚文本要符合语义,不要强行插入

2. 多样化:同一目标用不同锚文本(避免过度优化)

3. 关键词丰富:锚文本本身就是长尾词

2.2 锚文本词库(按目标页类型)

| 目标页类型 | 锚文本模板 |

|---|---|

| 八字入门文章 | 「八字排盘是什么」「八字入门」「新手如何看命盘」|

| 流年文章 | 「2026 丙午马年运势」「大运流年分析」「未来十年」|

| 喜用神文章 | 「喜用神判定」「五行喜忌」「日主强弱」|

| MBTI 文章 | 「MBTI 与八字」「MBTI 性格解析」「依恋类型」|

| 算法文章 | 「喜用神算法 spec」「流年模板」|

2.3 同主题互链密度

| 文章长度 | 推荐互链数 |

|---|:---:|

| < 500 字 | 1-2 个 |

| 500-1500 字 | 3-5 个 |

| > 1500 字 | 5-8 个 |

---

三、自动互链算法(V1.0)

3.1 互链触发条件

`python

def find_internal_links(article: dict, all_articles: list) -> list:

"""找出文章内部互链"""

links = []

article_tags = set(article.get('tags', []))

article_category = article.get('category', '')

article_keywords = extract_keywords(article['content'])

for other in all_articles:

if other['id'] == article['id']:

continue

# 1. 同分类(强相关)

if other.get('category') == article_category:

links.append({

'target': other,

'relevance': 'same_category',

'score': 80,

'anchor_text': other['title'][:30]

})

continue

# 2. 标签重合(中等相关)

other_tags = set(other.get('tags', []))

tag_overlap = article_tags & other_tags

if len(tag_overlap) >= 2:

links.append({

'target': other,

'relevance': 'shared_tags',

'score': 60 + len(tag_overlap) * 10,

'anchor_text': extract_anchor(other, article_keywords)

})

continue

# 3. 关键词共现(弱相关)

kw_overlap = article_keywords & extract_keywords(other['content'])

if len(kw_overlap) >= 3:

links.append({

'target': other,

'relevance': 'keyword_overlap',

'score': 40 + len(kw_overlap) * 5,

'anchor_text': extract_anchor(other, article_keywords)

})

# 按 score 排序,取 top 5

return sorted(links, key=lambda x: -x['score'])[:5]

`

3.2 锚文本自动生成

`python

ANCHOR_TEMPLATES = {

'八字入门': [

'八字排盘是什么',

'新手如何看懂命盘',

'四柱八字入门',

'八字基础教程',

'命盘基础知识'

],

'喜用神': [

'喜用神判定',

'五行喜忌',

'日主强弱',

'喜用神算法',

'用神选取'

],

'流年': [

'2026 丙午马年',

'大运流年',

'未来十年运势',

'流年模板',

'流年分析'

],

'MBTI': [

'MBTI 性格解析',

'八字推导 MBTI',

'依恋类型',

'心理画像',

'人格特质'

]

}

def extract_anchor(target_article: dict, source_keywords: set) -> str:

"""从目标文章提取最佳锚文本"""

target_tags = target_article.get('tags', [])

target_category = target_article.get('category', '')

# 1. 优先匹配 tag

for tag in target_tags:

if tag in ANCHOR_TEMPLATES:

import random

return random.choice(ANCHOR_TEMPLATES[tag])

# 2. 退而求其次:目标标题片段

return target_article['title'][:20]

`

3.3 互链插入位置

| 位置 | 适用 | 示例 |

|---|---|---|

| 首段后 | 引出相关概念 | "八字排盘是什么 → 详见..." |

| 中段过渡 | 解释细节时 | "戊土日主详解 → 推荐阅读..." |

| 文末 | 延伸阅读 | "想了解更多命理知识?→ 八字入门" |

密度控制:每 300-500 字 1 个互链

---

四、对接前端(Field Spec)

`typescript

// 文章详情页:相关推荐数据

interface RelatedArticle {

id: string;

title: string;

slug: string;

category: string;

relevance: 'same_category' | 'shared_tags' | 'keyword_overlap';

score: number;

anchor_text: string;

suggested_position: 'top' | 'middle' | 'bottom';

}

// 文章页底部:「延伸阅读」板块

interface ExtendedReading {

by_category: RelatedArticle[]; // 同分类 2-3 篇

by_tags: RelatedArticle[]; // 同标签 2-3 篇

by_keywords: RelatedArticle[]; // 关键词共现 1-2 篇

}

`

前端渲染 HTML

`html

`

---

五、排盘结果页 → 文章钩子

5.1 钩子策略

排盘结果页(result.html)每个模块底部,自动推荐相关文章:

| 模块 | 推荐文章类型 |

|---|---|

| 模块 1(四柱命盘)| 八字入门、算法原理 |

| 模块 3(人格)| MBTI 与八字、依恋类型 |

| 模块 7(流年)| 流年详解、2026 运势 |

| 模块 8(大运)| 大运分析、十年一步 |

5.2 钩子 HTML 示例

`html

想了解更多 {日主}{流年} 的运势?

阅读《{related_title}》→

`

---

六、自动互链脚本(V1.0)

`python

#!/usr/bin/env python3

"""

internal_linker.py · 自动为 KB 文章添加内链

"""

import json

import urllib.request

from collections import defaultdict

API_BASE = "https://www.wanshifwuyou.com/api/kb/articles"

def fetch_all_articles():

"""拉取 KB 所有文章"""

req = urllib.request.Request(f"{API_BASE}?page=1&size=500")

with urllib.request.urlopen(req) as resp:

data = json.loads(resp.read())

return data.get('items', [])

def extract_keywords(content: str) -> set:

"""提取文章关键词(简单实现:基于词频)"""

# 实际生产可用 jieba

keywords = set()

for word in ['八字', '大运', '流年', '喜用神', 'MBTI', '五行', '日主', '调候', '格局', '命盘']:

if word in content:

keywords.add(word)

return keywords

def find_links(article: dict, all_articles: list, top_n: int = 5) -> list:

"""为单篇文章找互链"""

links = []

article_tags = set(article.get('tags', '').split(','))

article_keywords = extract_keywords(article.get('summary', '') + article.get('title', ''))

for other in all_articles:

if other['id'] == article['id']:

continue

other_tags = set(other.get('tags', '').split(','))

other_keywords = extract_keywords(other.get('summary', '') + other.get('title', ''))

score = 0

relevance = None

# 同分类

if other.get('category') == article.get('category'):

score = 80

relevance = 'same_category'

# 标签重合

elif len(article_tags & other_tags) >= 2:

score = 60 + len(article_tags & other_tags) * 10

relevance = 'shared_tags'

# 关键词共现

elif len(article_keywords & other_keywords) >= 3:

score = 40 + len(article_keywords & other_keywords) * 5

relevance = 'keyword_overlap'

if score > 0:

links.append({

'target_id': other['id'],

'target_title': other['title'],

'target_category': other.get('category', ''),

'relevance': relevance,

'score': score,

'anchor_text': other['title'][:20]

})

return sorted(links, key=lambda x: -x['score'])[:top_n]

def main():

print("🔍 拉取 KB 所有文章...")

articles = fetch_all_articles()

print(f"📚 共 {len(articles)} 篇")

results = []

for article in articles:

links = find_links(article, articles)

if links:

results.append({

'source_id': article['id'],

'source_title': article['title'],

'related': links

})

# 保存到文件供前端调用

output = {

'total': len(articles),

'articles_with_related': len(results),

'data': results

}

Path('/home/admin/.openclaw/workspace/workbuddy/data/internal_links.json').write_text(

json.dumps(output, ensure_ascii=False, indent=2),

encoding='utf-8'

)

print(f"✅ 互链数据生成完成:{len(results)} 篇文章有相关推荐")

print(f"📁 保存到 data/internal_links.json")

if __name__ == '__main__':

main()

`

---

七、对接需求

7.1 老大需要做的事

| 操作 | 命令 |

|---|---|

| 跑互链脚本 | python3 internal_linker.py |

| 同步到公网 | SSH 上服务器 → 复制 JSON 到前端目录 |

| 重启服务 | pm2 reload openclaw-gateway |

7.2 我能自主做的

| 任务 | 状态 |

|---|---|

| 互链算法设计 | ✅ |

| 锚文本词库 | ✅ |

| 钩子 HTML 模板 | ✅ |

| 自动脚本 | ✅ |

| 跑通测试(125 篇)| ⏳ 老大拍板后跑 |

---

八、SEO 7 天清单第 4 项完成度

| # | 任务 | 状态 |

|:---:|---|:---:|

| 1 | 互链策略设计 | ✅ |

| 2 | 互链算法 | ✅ |

| 3 | 锚文本词库 | ✅ |

| 4 | 自动脚本 | ✅ |

| 5 | 实际运行 | ⏳ 老大 SSH |

---

九、归档信息

| 项目 | 内容 |

|---|---|

| 文件名 | internal-linking-strategy-20260807.md |

| 作者 | 总指挥(优优在手)|

| 完成时间 | 2026-08-07 10:42 |

| 字数 | 约 3500 字 |

| 分类 | SEO 优化 |

| 状态 | 草稿态(待老大审批后转正式)|

📊 这篇文章对你有帮助吗?

点击星星评分(0 人评分,平均 0.0 分)