sitemap.xml emits relative <loc> values, so search engines reject it
Đá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 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.
- 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
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của shift-org/shift-docs
-
Unknown --db values report a TypeError instead of the intended errorCó thể đã có người làm @gangster đã nhận 60 ngày trước. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
shift-org/shift-docs#1091 ·
-
validateRideLength accepts any Object.prototype key as a ride lengthCó thể đã có người làm @gangster đã nhận 60 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
shift-org/shift-docs#1089 ·
-
Favorites page fetches every favorite because getDaily's guard is invertedCó thể đã có người làm @gangster đã nhận 60 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
shift-org/shift-docs#1087 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 58/100
shift-org/shift-docs#1072 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 58/100
shift-org/shift-docs#1054 ·
Tất cả issue của shift-org/shift-docs
Issue tương tự
-
[quality] useFocusTrap's Shift+Tab wrap and non-Tab/non-Escape key arms are never driven end to endCó thể đã có người làm @hivecommons-hive đã nhận hôm nay. Đang mởagent/quality hive/covered-by-pr hive/hosted-available-lke648397-260827-5n31 quality testing
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[aw] Upgrade availableĐang mởagentic-workflows
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
githubnext/gh-aw-workshop#4220 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
JuliusBrussee/caveman#1189 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
priority:low ready-for-dev
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
OpenHands/extensions#738 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
invoiceninja/invoiceninja#13320 ·
Maintainer thường phản hồi trong vòng 1 ngày