mirror of
https://github.com/peter-tanner/peter-tanner.github.io.git
synced 2024-11-30 12:00:18 +08:00
1.5 KiB
1.5 KiB
title | author | date | categories | tags | ||
---|---|---|---|---|---|---|
Adding the canonical tag to Gitea to prevent duplicate spam | peter | 2024-06-29 02:55:28 +0800 |
|
|
Gitea doesn't include the canonical tag in their pages, leading to a lot of duplicate pages being indexed by Google. Each page being indexed has a different sorting option, or other superflous parameter.
Duplicate without user-selected canonical
These pages aren't indexed or served on Google
Not sure if having a lot of these errors affects SEO but I've noticed a lot of my real pages are being discovered but not indexed by Google.
To fix this,
- Create a
custom/templates/base/
directory under your Gitea installation. In my case it is in/var/lib/gitea/custom/templates/base/
. - CD to the base directory and run
wget https://raw.githubusercontent.com/go-gitea/gitea/main/templates/base/head.tmpl
. Make sure your Gitea is updated to the latest version, or choose the right version instead of themain
branch. - Modify
head.tmpl
: Add this line somewhere in the<head>
section:
<link rel="canonical" href="{{AppUrl}}{{if $.Link}}{{slice $.Link 1}}{{end}}" />
- Restart the gitea service