Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

sitemap.xml emits relative <loc> values, so search engines reject it

未关闭
#1,082 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 7 天内回复

@dduugg 已经在做这个了。

开始于 2026年7月10日。

  • #1084 来自 @dduugg —— 未关闭

评估

难度
4/5
预计耗时
3-5 天
新手友好度
68/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
冷清
技术栈
hugo, javascript

调研方向

从 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 with sitemap: disable in the page's front matter.
  • #1068 adds a robots.txt with a Sitemap: 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 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

shift-org/shift-docs 的其他 Issue

查看 shift-org/shift-docs 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。