🎯 SEO自动化概览
OpenClaw可以通过Cron任务+Agent能力实现全自动的SEO工作流:
- 批量生成 — 每天自动生成5-10个SEO优化页面
- Sitemap — 自动更新sitemap.xml
- 死链检查 — 定期检查并修复死链
- Meta优化 — 自动生成优化的title和description
- 内链建设 — 自动添加相关页面的内部链接
📄 批量页面生成
SEO页面生成Skill
# SKILL.md - SEO页面生成器
## 触发条件
当收到"生成SEO页面"、"批量生成工具页"指令时触发。
## 执行步骤
### 1. 关键词研究
使用 web_search 搜索目标关键词:
- 搜索量分析
- 竞争度评估
- 长尾词挖掘
### 2. 内容规划
每个页面包含:
- H1标题(含关键词)
- Meta description(150-160字符)
- 功能介绍
- 使用方法
- 最佳实践
- 代码示例
- 相关链接(内链)
### 3. 页面生成
使用 write 工具生成HTML文件:
- 路径:/var/www/miaoquai/tools/{slug}.html
- 格式:标准SEO HTML模板
- 内链:至少3-5个相关页面链接
### 4. Sitemap更新
自动更新 /var/www/miaoquai/sitemap.xml
批量生成脚本
# Agent执行批量生成的逻辑
topics = [
"openclaw-rag-integration",
"openclaw-vector-database",
"openclaw-agent-memory",
"openclaw-tool-calling",
"openclaw-prompt-engineering"
]
for topic in topics:
# 1. 搜索相关资料
search_results = web_search(topic)
# 2. 生成页面内容
content = generate_seo_page(topic, search_results)
# 3. 写入文件
write(f"/var/www/miaoquai/tools/{topic}.html", content)
# 4. 更新sitemap
update_sitemap(topic)
📐 页面模板系统
标准SEO页面模板
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>{keyword} - 完整指南 | 妙趣AI</title>
<meta name="description" content="{meta_description}">
<meta name="keywords" content="{keywords}">
<link rel="canonical" href="https://miaoquai.com/tools/{slug}.html">
<meta property="og:title" content="{title}">
<meta property="og:description" content="{meta_description}">
</head>
<body>
<!-- Hero区域 -->
<div class="hero">
<h1>{h1_title}</h1>
<p>{subtitle}</p>
</div>
<!-- 目录 -->
<div class="toc">{table_of_contents}</div>
<!-- 内容区域 -->
<div class="content">
<h2>功能介绍</h2>
<!-- 详细介绍 -->
<h2>使用方法</h2>
<!-- 步骤说明 -->
<h2>最佳实践</h2>
<!-- 实践建议 -->
<h2>代码示例</h2>
<!-- 代码块 -->
<h2>相关资源</h2>
<!-- 内链 -->
</div>
<!-- 导航链接 -->
<div class="nav-links">
<a href="/tools/{prev}.html">← 上一篇</a>
<a href="/tools/">工具教程首页</a>
<a href="/tools/{next}.html">下一篇 →</a>
</div>
</body>
</html>
🗺️ Sitemap自动更新
Sitemap生成脚本
# 生成sitemap.xml
#!/bin/bash
SITEMAP="/var/www/miaoquai/sitemap.xml"
BASE_URL="https://miaoquai.com"
echo '<?xml version="1.0" encoding="UTF-8"?>' > $SITEMAP
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' >> $SITEMAP
# 首页
echo " <url><loc>$BASE_URL/</loc><priority>1.0</priority></url>" >> $SITEMAP
# 遍历所有HTML文件
find /var/www/miaoquai -name "*.html" | while read file; do
path=$(echo $file | sed 's|/var/www/miaoquai||' | sed 's|/index.html|/|')
date=$(date -r "$file" +%Y-%m-%d)
echo " <url><loc>$BASE_URL$path</loc><lastmod>$date</lastmod></url>" >> $SITEMAP
done
echo '</urlset>' >> $SITEMAP
Agent自动更新
# 在SKILL.md中添加sitemap更新步骤
## 执行步骤
...(生成页面后)
### 更新Sitemap
```bash
# 执行sitemap生成脚本
bash /root/.openclaw/scripts/update-sitemap.sh
# 验证sitemap
curl -s https://miaoquai.com/sitemap.xml | head -20
```
🔗 死链检查
死链检查Skill
# SKILL.md - 死链检查器
## 执行步骤
### 1. 获取所有页面链接
```bash
grep -roh 'href="[^"]*"' /var/www/miaoquai/*.html | sort -u
```
### 2. 逐个检查
对于每个链接:
- 内部链接:检查文件是否存在
- 外部链接:使用curl检查HTTP状态码
### 3. 生成报告
输出格式:
| 链接 | 状态 | 来源页面 | 建议 |
|------|------|----------|------|
| /tools/xxx.html | 404 | page1.html | 删除或重定向 |
| https://external.com | 500 | page2.html | 标记为外部 |
### 4. 自动修复
- 删除指向404的内部链接
- 更新过期的外部链接
- 添加301重定向
批量检查命令
# 检查所有内部链接
grep -roh 'href="/[^"]*"' /var/www/miaoquai/ | sort -u | while read link; do
path=$(echo $link | sed 's/href="//' | sed 's/"//')
file="/var/www/miaoquai$path"
if [ ! -f "$file" ]; then
echo "BROKEN: $link"
fi
done
# 检查外部链接
grep -roh 'href="https://[^"]*"' /var/www/miaoquai/ | sort -u | while read link; do
url=$(echo $link | sed 's/href="//' | sed 's/"//')
status=$(curl -s -o /dev/null -w "%{http_code}" "$url" --max-time 5)
if [ "$status" != "200" ]; then
echo "BROKEN ($status): $url"
fi
done
🔗 内链优化
内链策略
# 每个页面应该包含的内链:
1. 相关工具页面(3-5个)
2. 教程/指南页面(2-3个)
3. 首页/分类页(1-2个)
4. 上一篇/下一篇导航
# 内链添加规则:
- 使用描述性锚文本
- 链接到相关性最高的页面
- 避免过度链接(每页5-10个为宜)
- 确保链接自然融入内容
自动内链生成
# Agent生成内链的逻辑
related_pages = find_related_pages(current_page_topic, all_pages)
for page in related_pages:
# 在合适的位置插入链接
content = insert_internal_link(
content,
url=f"/tools/{page.slug}.html",
anchor_text=page.title,
context=page.summary
)
⏰ 定时SEO任务
# Cron配置示例
# 每天凌晨1点:生成新页面
0 1 * * * - SEO页面生成(5-10个新页面)
# 每天凌晨2点:SEO巡检
0 2 * * * - 死链检查、Meta检查、Sitemap更新
# 每周日凌晨3点:深度审计
0 3 * * 0 - 全站SEO审计、竞品分析、关键词更新
💡 SEO自动化最佳实践
- 质量优先 — 不要为了数量牺牲质量
- 关键词研究 — 每次生成前先做关键词研究
- 内容去重 — 避免生成重复内容
- 定期审计 — 每周检查SEO效果
- 监控排名 — 跟踪关键词排名变化