Skip to content

Instantly share code, notes, and snippets.

@robertknight
Created July 7, 2022 10:37
Show Gist options
  • Select an option

  • Save robertknight/4afaabbb35d4126c2705251febb55847 to your computer and use it in GitHub Desktop.

Select an option

Save robertknight/4afaabbb35d4126c2705251febb55847 to your computer and use it in GitHub Desktop.
How Hypothesis interacts with canonical links (`<link rel=canonical>`)
@robertknight
Copy link
Copy Markdown
Author

Users would be able to edit them, although it's prone to voluntary discrepancies if someone were in a bad mood.

I think we need to be able to solve this without any user input. The situation would be pretty difficult to explain in simple terms to someone who doesn't know what canonical links are.

What about using MutationObserver to detect location-change ?

Yes, this is planned. hypothesis/client#4629 uses a combination of window.navigation (if available), monkey-patching window.history (otherwise) and MutationObserver to detect changes in the browser URL and links in the <head> element.

I'm currently doing some investigation to understand how canonical URLs are used in the wild and get an understanding of how many sites are affected by this or related issues. Reloading the page might work, but it would also lose some state and make the navigation slower, so I'd prefer to avoid that.

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