sitemap.xml emits relative <loc> values, so search engines reject it
维护者通常 7 天内回复
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 68/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- hugo, javascript
- 领域
- build-system, devops, web-dev
调研方向
从 site/config/_default/hugo.toml 和 netlify.toml 中现有的命令行开始,然后检查列出的主题 partial 中对 absURL 的使用,以保留本地和预览行为。按 Netlify 上下文配置基本 URL,并验证 sitemap.xml 为所有条目输出完全限定的 loc 值,同时检查 issue 中描述的 /404/ 和 robots.txt 相关行为。
由索引模型根据 Issue 内容生成。
描述
https://www.shift2bikes.org/sitemap.xml builds and serves fine (200), but every entry is a relative path:
<url>
<loc>/pages/bike-summer/</loc>
</url>
<url>
<loc>/archive/get-lit/</loc>
<lastmod>2017-11-13T08:19:34+00:00</lastmod>
</url>
The sitemap protocol requires <loc> to be a fully qualified URL, so the 72 entries currently in the file are almost certainly being discarded.
Cause
site/config/_default/hugo.toml sets:
baseURL = "/"
Hugo builds <loc> from each page's .Permalink, which is derived from baseURL, so the permalinks come out relative.
This is not a one-line fix
baseURL = "/" is load-bearing rather than an oversight. The theme uses absURL for essentially every asset, and for the calendar's own API calls:
site/themes/s2b_hugo_theme/layouts/partials/cal/scripts.html:140: url: '{{ absURL "api/events.php" }}',
site/themes/s2b_hugo_theme/layouts/partials/head-content.html:29: <link rel="icon" href="{{ absURL "favicon.ico" }}">
site/themes/s2b_hugo_theme/layouts/partials/cal/up-next.html:1: <script src="{{ absURL "lib/fullcalendar/core/main.min.js" }}"></script>
With baseURL = "/" these resolve same-origin, which is what lets the site work unchanged on localhost, on netlify deploy previews, and in production. Hardcoding the production URL into hugo.toml would make deploy previews and local dev load their scripts from, and fetch their event data from, www.shift2bikes.org.
Suggested approach
Set HUGO_BASEURL per netlify context rather than in hugo.toml, so each deploy gets the origin it is actually served from:
- production: the canonical
https://www.shift2bikes.org/ - deploy previews and branch deploys:
$DEPLOY_PRIME_URL - local dev (
npm run dev,-e development): leave as/
Netlify exposes both URL and DEPLOY_PRIME_URL to the build, and hugo reads HUGO_BASEURL from the environment, so this can live in the command lines already present in netlify.toml.
Related
- The sitemap also lists
/404/. Worth excluding, most simply withsitemap: disablein the page's front matter. - #1068 adds a
robots.txtwith aSitemap:line pointing here. That line becomes correct once this is fixed. See the discussion on the PR for #1068.
- 主要语言
- JavaScript
- 星标
- 30
- 派生
- 26
- 平均合并
- 6 天 24 分钟
- 30 天内合并 PR
- 6
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
shift-org/shift-docs 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 65/100
shift-org/shift-docs#1127 ·
维护者通常 7 天内回复
-
Export links and the webcal feed 404 under npm run dev可能已有人在做 @dduugg 于 7 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 83/100
shift-org/shift-docs#1121 ·
维护者通常 7 天内回复
-
Unknown --db values report a TypeError instead of the intended error可能已有人在做 @gangster 于 79 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 88/100
shift-org/shift-docs#1091 ·
维护者通常 7 天内回复
-
validateRideLength accepts any Object.prototype key as a ride length可能已有人在做 @gangster 于 79 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
shift-org/shift-docs#1089 ·
维护者通常 7 天内回复
-
Favorites page fetches every favorite because getDaily's guard is inverted可能已有人在做 @gangster 于 79 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
shift-org/shift-docs#1087 ·
维护者通常 7 天内回复
查看 shift-org/shift-docs 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 66/100
lyswhut/lx-music-desktop#3026 ·
-
good first issue server
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 67/100
openstreetmap/iD#13054 ·
维护者通常 1 天内回复
-
community marketing priority: low
难度 2/5 1-3 小时 新手友好度 72/100
TMHSDigital/Free-Game-Dev-Assets#151 ·
维护者通常 1 天内回复
-
Read a vector index's quantization back on Neo4j 2026.10, which reports vector.quantization.type未关闭
难度 2/5 1-3 小时 新手友好度 78/100
liberation-data/drivine#231 ·
维护者通常 1 天内回复