Skip to content

fix: 内部リンクを末尾スラッシュ付きの正規 URL に揃えて 307 リダイレクトをなくす - #817

Open
devin-ai-integration[bot] wants to merge 2 commits into
mainfrom
devin/1795145962-canonical-trailing-slash
Open

devin-ai-integration[bot] wants to merge 2 commits into
mainfrom
devin/1795145962-canonical-trailing-slash

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

記事・タグ・固定ページへの内部リンクを、末尾スラッシュ付きの正規 URL(例: /posts/nespresso-mold/)に揃えました。これまでは /posts/<slug> へリンクしていたため、記事やタグを開くたびに 307 で /posts/<slug>/ へリダイレクトされ、1 往復ぶん待ち時間が増えていました。

  • src/lib/posts.ts: getPublishedPosts() と getPublishedStandalonePages() が返す url を末尾スラッシュ付きに変更(一覧と RSS に反映)
  • src/components/PostMetadata.astro: タグリンクを /tags/${tag}/ に変更
  • 記事本文と about に直書きされていた内部リンク 4 件を修正
  • tests/e2e/specs/canonical-links.spec.ts: ビルド後の HTML・RSS・sitemap の内部リンクがリダイレクトなしで 200 を返すことを確認する回帰テストを追加
  • Worker と Astro の URL ポリシーは変えていません

計測結果

指標 変更前 変更後
3xx を返す内部リンク(全 48 ページ、698 リンク中) 106 0
3xx を返す内部リンク先(重複なし) 43 0
トップから記事へ移動するときのリダイレクト回数 1 0

本番(sur33.com、2026-11-20、curl 5 回の中央値、Cloudflare PDX 経由)では、リダイレクトありの /posts/zshrc-startup-slow-cause-and-fix は 0.186 秒、正規 URL へ直接アクセスすると 0.128 秒でした。記事・タグへの移動 1 回あたり、約 24〜60 ms 短くなる見込みです。回線の遅延が大きいモバイル環境では、短縮幅はさらに大きくなると考えられます(未計測)。

再現方法

pnpm run build:ci
pnpm exec wrangler dev   # dist を Worker 経由で配信
# ビルド済み HTML の内部 <a href> をすべて取得し、3xx を返すものを数える
# 本番での差:
for i in 1 2 3 4 5; do curl -so /dev/null -L --compressed -w '%{time_total} %{num_redirects}\n' https://sur33.com/posts/nespresso-mold; done
for i in 1 2 3 4 5; do curl -so /dev/null -L --compressed -w '%{time_total} %{num_redirects}\n' https://sur33.com/posts/nespresso-mold/; done

コスト・注意点

  • RSS の記事 URL(link / guid)が末尾スラッシュ付きに変わるため、一部のフィードリーダーで既存の記事が新着として再表示される可能性があります。
  • 今後 Markdown に内部リンクを書くときも、末尾スラッシュ付きで書く必要があります(docs/layouts.md に追記しました)。

テスト

  • pnpm run lint: エラー 0
  • pnpm run test:worker: 73 件成功
  • pnpm run test:e2e --project=chromium: 71 件成功、2 件スキップ

Latency Optimizer opened this PR for Daiki
Implemented in session Speed up blog page loads at sur33.com
Review with Devin · Open in Devin Desktop


Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access that start with 'Devin'.

  • Disable automatic comment, CI, and merge conflict monitoring

@coderabbitai

coderabbitai Bot commented Nov 20, 2026

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 877ef4db-fdfb-4e87-be67-9a4d4d8e3270

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
blog a512466 Commit Preview URL

Branch Preview URL
Nov 20 2026, 03:48 AM

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants