Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add canonical link header #963

Merged
merged 1 commit into from
Aug 30, 2019
Merged

Conversation

lidel
Copy link
Contributor

@lidel lidel commented Aug 29, 2019

Fix #564

Change

This PR adds canonical URL in form of HTML <link> tag in the header of each page.

Example

webUrl = https://en.wikipedia.org/wiki/
articleId = Mew (Pokémon) (note é)

produces:

<link rel="canonical" href="https://en.wikipedia.org/wiki/Mew_(Pok%C3%A9mon)" />

Motivation

As noted in #564, HTML snapshot should point at canonical URL.
It improves semantics and help search engines to deduplicate relevant
results when multiple snapshots are published on the web.

Closes #564 cc @kelson42, ipfs/distributed-wikipedia-mirror#48

HTML snapshot should point at canonical URL.
It improves semantics and help search engines to deduplicate relevant
results when multiple snapshots are published on the web.

Closes openzim#564

License: MIT
Signed-off-by: Marcin Rataj <lidel@lidel.org>
@lidel lidel force-pushed the feat/canonical-link branch from ac6a4a4 to f419861 Compare August 29, 2019 13:50
@kelson42 kelson42 requested a review from ISNIT0 August 29, 2019 14:12
@kelson42
Copy link
Collaborator

@lidel Thank you for this PR, this will be reviewed in within the next days.

@codecov
Copy link

codecov bot commented Aug 29, 2019

Codecov Report

Merging #963 into master will increase coverage by 0.04%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #963      +/-   ##
==========================================
+ Coverage   62.24%   62.29%   +0.04%     
==========================================
  Files          20       20              
  Lines        1682     1684       +2     
  Branches      340      340              
==========================================
+ Hits         1047     1049       +2     
  Misses        465      465              
  Partials      170      170
Impacted Files Coverage Δ
src/util/saveArticles.ts 67.87% <100%> (ø) ⬆️
src/util/misc.ts 53.84% <100%> (+0.47%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 544dff7...f419861. Read the comment docs.

@Jaifroid
Copy link
Collaborator

@lidel, articles in ZIMs made by mwoffliner currently have in their footer a link to the specific revision that corresponds to the text from which the snapshot is made. For example, it looks like this:

<a title="Last edited on 2019-08-06" class="external text" href="https://en.wikipedia.org/wiki/Aztecs?oldid=909673122" target="_blank">

This leads to a page like that in screenshot below.

Shouldn't your canonical link also contain the revision ID?

image

@lidel
Copy link
Contributor Author

lidel commented Aug 29, 2019

@Jaifroid Good question! I believe the semantic meaning of <link rel="canonical" is not an "exact copy" but a "preferred version". RFC6596 describes it like this:

In regard to the link relation type, "canonical" can be described
informally as the author's preferred version of a resource.

My understanding is that in the context of a wiki page the "preferred version" is the latest version, and that is what this PR links to.

@Jaifroid
Copy link
Collaborator

OK @lidel, thanks for the explanation.

Copy link
Contributor

@ISNIT0 ISNIT0 left a comment

Choose a reason for hiding this comment

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

Looks great, thanks @lidel

@ISNIT0 ISNIT0 merged commit 510d2bb into openzim:master Aug 30, 2019
lidel added a commit to lidel/zim-tools that referenced this pull request Feb 27, 2021
Without this search engines crawling unpacked version may produce duplicated results.
It does not cost much to have it, and avoids issues like ones linked below.

Ref.
openzim/mwoffliner#963
ipfs/distributed-wikipedia-mirror#65
https://en.wikipedia.org/wiki/Canonical_link_element
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.

Add canonical link
4 participants