Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

Overwrite canonical without html with sphinx extension #1905

Merged

Conversation

angelinekwan
Copy link
Collaborator

@angelinekwan angelinekwan commented May 15, 2023

What changed, and why it matters

To resolve issue #1691 , canonical url updated to
/index.html -> /
and the rest of the pages without .html

Solution

Create a custom Sphinx extension that adds a HTML context event to override the pageurl variable, which is used by Furo to generate the canonical URL.

Demo

https://overwrite-canonical-without.devportal.pages.dev/
<link rel="canonical" href="https://docs.aiven.io/">

https://overwrite-canonical-without.devportal.pages.dev/docs/platform
<link rel="canonical" href="https://docs.aiven.io/docs/platform">

Screenshot 2023-05-19 at 18 30 08

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented May 15, 2023

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 38f786a
Status: ✅  Deploy successful!
Preview URL: https://0328b3ad.devportal.pages.dev
Branch Preview URL: https://overwrite-canonical-without.devportal.pages.dev

View logs

@angelinekwan angelinekwan marked this pull request as draft May 15, 2023 15:51
@angelinekwan angelinekwan marked this pull request as ready for review May 29, 2023 18:44
@celestehorgan
Copy link
Contributor

Hi @angelinekwan!

I did the following:

  1. Navigated to https://docs.aiven.io/docs/products/redis/concepts/high-availability-redis and confirmed the incorrect canonical URL, https://docs.aiven.io/docs/products/redis/concepts/high-availability-redis.html
  2. Navigated to https://overwrite-canonical-without.devportal.pages.dev/docs/products/redis/concepts/high-availability-redis and confirmed the correct canonical URL, https://docs.aiven.io/docs/products/redis/concepts/high-availability-redis.

This LGTM!

@celestehorgan celestehorgan merged commit afb2a00 into main May 30, 2023
@celestehorgan celestehorgan deleted the overwrite-canonical-without-html-with-sphinx-extension branch May 30, 2023 13:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants