设置 Google News Publisher Center 并实现动态新闻 sitemap,确保你的文章能够被快速发现和收录。
前置条件
- 已在 Google Search Console 中验证的网站
- 定期发布的新闻内容
- 实现 XML sitemap 的技术能力
- 用于自动生成 sitemap 的服务器访问权限
第 1 步:准备你的网站
内容要求
在申请 Google News 之前:
- 发布至少 10-20 篇高质量新闻文章
- 持续稳定发布 2 周以上
- 确保清晰的作者署名
- 实现合理的 URL 结构
- 移除任何违反政策的内容
技术要求
- 快速的页面加载时间(LCP < 2.5s)
- 移动端自适应设计
- 启用 HTTPS
- 正确的 robots.txt 配置
- 所有文章均带有 NewsArticle schema 标记
第 2 步:申请 Google News Publisher Center
- 前往 news.google.com/publisher-center
- 点击 "Add Publication"
- 输入你的出版物名称
- 验证网站所有权(通过 Search Console)
- 配置你的出版物设置:
- 出版物名称
- 语言
- 地区
- 网站 URL
栏目配置
创建与你的内容分类相匹配的栏目:
Sections:
├── Technology
│ ├── AI & Machine Learning
│ ├── Software & Apps
│ └── Gadgets
├── Business
│ ├── Markets
│ └── Startups
└── Science
├── Space
└── Environment
第 3 步:实现新闻 sitemap
服务端 sitemap 生成
from datetime import datetime, timedelta
from xml.etree.ElementTree import Element, SubElement, tostring
from xml.dom import minidom
def generate_news_sitemap(articles):
urlset = Element('urlset')
urlset.set('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9')
urlset.set('xmlns:news', 'http://www.google.com/schemas/sitemap-news/0.9')
cutoff = datetime.now() - timedelta(hours=48)
for article in articles:
if article['published'] < cutoff:
continue
url = SubElement(urlset, 'url')
loc = SubElement(url, 'loc')
loc.text = article['url']
news = SubElement(url, 'news:news')
publication = SubElement(news, 'news:publication')
name = SubElement(publication, 'news:name')
name.text = 'Example News'
lang = SubElement(publication, 'news:language')
lang.text = 'en'
pub_date = SubElement(news, 'news:publication_date')
pub_date.text = article['published'].isoformat()
title = SubElement(news, 'news:title')
title.text = article['title']
xml_str = tostring(urlset, encoding='unicode')
pretty_xml = minidom.parseString(xml_str).toprettyxml(indent=" ")
return pretty_xml
用于定期更新的 Cron 任务
# Update news sitemap every 15 minutes
*/15 * * * * /usr/bin/python3 /path/to/generate_news_sitemap.py
第 4 步:配置 Indexing API
设置服务账号
- 前往 Google Cloud Console
- 创建一个新项目
- 启用 Indexing API
- 创建服务账号凭据
- 下载 JSON 密钥文件
- 将服务账号添加为 Search Console 所有者
实现
from google.oauth2 import service_account
from googleapiclient.discovery import build
def submit_url_to_indexing_api(url, key_file_path):
credentials = service_account.Credentials.from_service_account_file(
key_file_path,
scopes=['https://www.googleapis.com/auth/indexing']
)
service = build('indexing', 'v3', credentials=credentials)
request = service.urlNotifications().publish(
body={
'url': url,
'type': 'URL_UPDATED'
}
)
response = request.execute()
return response
# Submit after publishing
submit_url_to_indexing_api(
'https://example.com/2025/06/15/new-article',
'/path/to/credentials.json'
)
第 5 步:监控效果
Search Console 新闻报告
定期查看以下报告:
- 新闻效果(展示量、点击量)
- Top Stories 出现数据
- Discover 流量数据
- 新闻内容的索引覆盖率
自动化监控
def check_indexing_status(url, credentials):
service = build('indexing', 'v3', credentials=credentials)
response = service.urlNotifications().getMetadata(url=url).execute()
return response.get('latestUpdate', {}).get('notifyTime', 'Not indexed')
验证清单
- Publisher Center 申请已提交并通过审核
- 新闻 sitemap 正常生成
- sitemap 可在 /news-sitemap.xml 访问
- Robots.txt 引用了新闻 sitemap
- Indexing API 已配置并测试
- 所有文章均带有 NewsArticle schema
- 文章已出现在 Google News 中
- Search Console 显示新闻数据
- sitemap 的 cron 任务每 15 分钟运行一次
- 监控看板已设置完成