Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#1,082 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

@dduugg đang làm issue này rồi.

Từ ngày 10/7/2026.

  • #1084 của @dduugg — đang mở

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
68/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
hugo, javascript
Lĩnh vực
build-system, devops, web-dev

Hướng nghiên cứu

Bắt đầu với site/config/_default/hugo.toml và các dòng lệnh hiện có trong netlify.toml, sau đó xem xét các cách sử dụng absURL trong những partial của theme được liệt kê để giữ nguyên hành vi khi chạy cục bộ và khi preview. Cấu hình URL cơ sở theo từng ngữ cảnh Netlify và xác minh rằng sitemap.xml xuất các giá trị loc đầy đủ cho tất cả các mục, đồng thời kiểm tra hành vi liên quan của /404/ và robots.txt được mô tả trong issue.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
JavaScript
Star
30
Fork
25
Merge trung bình
9 phút
Pull request đã merge (30 ngày)
1

Chuẩn bị môi trường

  • Có Dockerfile hoặc tệp Docker Compose
  • Không có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của shift-org/shift-docs

Tất cả issue của shift-org/shift-docs

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.