Skip to content

Commit f2d0597

Browse files
committed
Prevent Googlebot from crawling compare and search pages
Add rel="nofollow" to all internal links targeting noindex pages and block /packages?*compare= in robots.txt.
1 parent d6f66d0 commit f2d0597

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

internal/ui/compare/templates.templ

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ templ CompareContent(names []string, excessNames []string, data chartdata.Data)
1313
if len(excessNames) > 0 {
1414
<div role="alert" class="alert alert-info mt-3">
1515
{ fmt.Sprintf("You can only compare up to %d packages. Only the first %d are shown.", layout.MaxCompareChartPackages, layout.MaxCompareChartPackages) }
16-
<a class="alert-link" href={ templ.SafeURL("/compare/packages/" + strings.Join(names, ",")) }>
16+
<a class="alert-link" rel="nofollow" href={ templ.SafeURL("/compare/packages/" + strings.Join(names, ",")) }>
1717
Remove { strings.Join(excessNames, ", ") } from list
1818
</a>
1919
</div>
@@ -22,7 +22,7 @@ templ CompareContent(names []string, excessNames []string, data chartdata.Data)
2222
@templ.JSONScript("", data)
2323
</popularity-chart>
2424
<div class="mt-3">
25-
<a class="btn btn-primary" href={ templ.SafeURL("/packages?compare=" + allNames(names, excessNames)) }>Edit selection</a>
25+
<a class="btn btn-primary" rel="nofollow" href={ templ.SafeURL("/packages?compare=" + allNames(names, excessNames)) }>Edit selection</a>
2626
</div>
2727
}
2828

internal/ui/fundetail/templates.templ

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ templ FunDetailHistoryContent(category string, data chartdata.Data, compareURL s
3838

3939
templ funCompareLink(compareURL string) {
4040
<div class="mt-4">
41-
<a class="btn btn-outline-primary" href={ templ.SafeURL(compareURL) }>
41+
<a class="btn btn-outline-primary" rel="nofollow" href={ templ.SafeURL(compareURL) }>
4242
<i class="bi bi-bar-chart-line me-1"></i>
4343
Compare all in detail
4444
</a>

internal/ui/gettingstarted/templates.templ

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ firefox-i18n-ru 1.22
1414
1515
10 of 320 results
1616
17-
See more results at <a class="code-link" href="/packages?query=firefox">https://pkgstats.archlinux.de/packages?query=firefox</a>`
17+
See more results at <a class="code-link" rel="nofollow" href="/packages?query=firefox">https://pkgstats.archlinux.de/packages?query=firefox</a>`
1818

1919
const codeShow = `$ pkgstats <strong>show</strong> firefox chromium epiphany konqueror
2020
firefox 63.53
2121
chromium 48.80
2222
epiphany 16.33
2323
konqueror 10.62
2424
25-
See more results at <a class="code-link" href="/compare/packages/chromium,epiphany,firefox,konqueror">https://pkgstats.archlinux.de/compare/packages/chromium,epiphany,firefox,konqueror</a>`
25+
See more results at <a class="code-link" rel="nofollow" href="/compare/packages/chromium,epiphany,firefox,konqueror">https://pkgstats.archlinux.de/compare/packages/chromium,epiphany,firefox,konqueror</a>`
2626

2727
const codeSubmit = `$ pkgstats <strong>submit --dump-json</strong>
2828
{

internal/ui/packagelist/templates.templ

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ templ PackagesContent(list *packages.PackagePopularityList, query string, curren
2020
if compareCount(compare) <= layout.MaxCompareChartPackages {
2121
<a
2222
class="d-inline-flex btn btn-primary"
23+
rel="nofollow"
2324
href={ templ.SafeURL("/compare/packages/" + compareNames(selectedPackages)) }
2425
>
2526
View History
@@ -34,7 +35,7 @@ templ PackagesContent(list *packages.PackagePopularityList, query string, curren
3435
if compareCount(compare) > layout.MaxSelectPackages {
3536
<div role="alert" class="alert alert-info mt-3 mb-4">
3637
{ fmt.Sprintf("You can only select up to %d packages. Only the first %d are shown.", layout.MaxSelectPackages, layout.MaxSelectPackages) }
37-
<a class="alert-link" href={ trimCompareURL(query, currentOffset, limit, compare) }>
38+
<a class="alert-link" rel="nofollow" href={ trimCompareURL(query, currentOffset, limit, compare) }>
3839
Remove { excessNames(compare) } from list
3940
</a>
4041
</div>
@@ -99,6 +100,7 @@ templ CompareTable(pkgs []packages.PackagePopularity, query string, offset int,
99100
<td class="align-middle text-end">
100101
<a
101102
class="text-danger"
103+
rel="nofollow"
102104
href={ toggleURL(query, offset, limit, compare, pkg.Name) }
103105
title={ "Remove " + pkg.Name }
104106
aria-label={ "Remove " + pkg.Name }
@@ -134,6 +136,7 @@ templ PackageTable(pkgs []packages.PackagePopularity, query string, offset int,
134136
if isSelected(compare, pkg.Name) {
135137
<a
136138
class="text-danger"
139+
rel="nofollow"
137140
href={ toggleURL(query, offset, limit, compare, pkg.Name) }
138141
title={ "Remove " + pkg.Name }
139142
aria-label={ "Remove " + pkg.Name }
@@ -143,6 +146,7 @@ templ PackageTable(pkgs []packages.PackagePopularity, query string, offset int,
143146
} else if compareCount(compare) < layout.MaxSelectPackages {
144147
<a
145148
class="text-primary"
149+
rel="nofollow"
146150
href={ toggleURL(query, offset, limit, compare, pkg.Name) }
147151
title={ "Add " + pkg.Name }
148152
aria-label={ "Add " + pkg.Name }
@@ -163,7 +167,7 @@ templ Pagination(total int, currentOffset int, limit int, query string, compare
163167
<ul class="pagination">
164168
if currentOffset > 0 {
165169
<li class="page-item">
166-
<a class="page-link" href={ paginationURL(query, prevOffset(currentOffset, limit), limit, compare) }>Previous</a>
170+
<a class="page-link" rel="nofollow" href={ paginationURL(query, prevOffset(currentOffset, limit), limit, compare) }>Previous</a>
167171
</li>
168172
} else {
169173
<li class="page-item disabled">
@@ -172,7 +176,7 @@ templ Pagination(total int, currentOffset int, limit int, query string, compare
172176
}
173177
if currentOffset+limit < total {
174178
<li class="page-item">
175-
<a class="page-link" href={ paginationURL(query, currentOffset+limit, limit, compare) }>Next</a>
179+
<a class="page-link" rel="nofollow" href={ paginationURL(query, currentOffset+limit, limit, compare) }>Next</a>
176180
</li>
177181
} else {
178182
<li class="page-item disabled">

root/robots.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
User-agent: Googlebot
2+
Disallow: /packages?*compare=
23
Allow: /
34

45
User-agent: bingbot

0 commit comments

Comments
 (0)