Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン
#1,082 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

@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
フォーク
25
平均マージ
9分
マージ済み PR(30日)
1

環境構築

  • Dockerfile または Docker Compose ファイルあり
  • プルリクエストのテンプレートなし
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

shift-org/shift-docs のほかの issue

shift-org/shift-docs の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。