TL;DR

用Hugo部署一个网站很简单,但部署完只是开始。更重要的是:部署之后,AI爬虫能不能正确读取和理解你的网站内容?本文覆盖从Hugo生成、nginx配置、Let’s Encrypt SSL到完整GEO技术资产部署的全流程。

环境

  • 腾讯云CVM(OpenCloudOS 8)或任意Linux VPS
  • Nginx 1.26
  • Hugo 静态站点
  • Let’s Encrypt SSL(certbot)

第一步:Hugo生成与部署

# 生成静态文件
hugo

# 上传到服务器
rsync -avz public/ root@your-server:/var/www/yoursite/

注意:不推荐 --minify 参数——可能导致HTML属性引号被移除,影响部分验证工具识别meta标签。

第二步:Nginx配置

server {
    listen 443 ssl http2;
    server_name your-domain.com;
    root /var/www/yoursite;
    index index.html;

    ssl_certificate     /etc/letsencrypt/live/your-domain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/your-domain.com/privkey.pem;

    location / {
        try_files $uri $uri.html $uri/ =404;
    }
}

server {
    listen 80;
    server_name your-domain.com;
    return 301 https://$host$request_uri;
}

重要细节:如果搜索引擎验证文件需要HTTP访问(如百度站长验证),HTTP server block中需要为验证文件路径单独配置不重定向的location。

第三步:GEO技术资产

在Hugo的 static/ 目录下放置以下文件——它们会被直接复制到站点根目录:

robots.txt

User-agent: DeepSeekBot
Allow: /
User-agent: Bytespider
Allow: /
User-agent: Baiduspider
Allow: /
Sitemap: https://your-domain.com/sitemap.xml

llms.txt

# 站点名称
> 一句话描述

## 核心页面
- [首页](https://域名) — 品牌介绍
- [服务](https://域名/services) — 服务详情
- [关于](https://域名/about) — 公司信息
- [联系](https://域名/contact)

ai.txt

Allow: *

JSON-LD(在 Hugo 模板 <head> 中)

<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "Organization",
  "name": "品牌名",
  "url": "https://域名",
  "description": "业务描述",
  "knowsAbout": ["关键词1", "关键词2"]
}
</script>

第四步:验证

# 确认AI爬虫文件可访问
curl -s https://your-domain.com/robots.txt
curl -s https://your-domain.com/llms.txt
curl -s https://your-domain.com/ai.txt

# 确认JSON-LD存在
curl -s https://your-domain.com | grep -o 'application/ld+json'

# 验证结构化数据
# 访问 https://validator.schema.org,输入你的网址

第五步:提交搜索引擎

部署完成后,去百度站长平台和Bing Webmaster手动提交sitemap,加速爬虫发现。百度的普通收录可能需要等待配额,Bing通常48小时内开始处理。

为什么Hugo是最佳选择

Hugo生成纯静态HTML。AI爬虫不用执行JS就能获取完整内容。相比之下,CSR的React/Vue站点,AI眼里的原始HTML可能只有 <div id="root"></div> ——从GEO角度看,这是灾难。

Hugo的优势:

  • 编译后为纯HTML文件,AI爬虫零障碍读取
  • static/目录直接映射到站点根目录,爬虫文件管理简单
  • 构建速度快,改一个字重新部署只需几秒