mirror of
https://github.com/imfing/hextra.git
synced 2025-05-18 14:46:35 -04:00
feat(seo): add page param to block Google indexing
Add a `noindex` param to page front matter to block Google indexing for specific pages or directories. This is useful for avoiding duplicate content in search results or preventing indexing of pages that shouldn't appear in search engines. - Adjust `head.html` for optional `noindex` param (default: false) - Document usage in `configuration.md` and clarify Flexsearch section
This commit is contained in:
parent
f194bc64e4
commit
128235e7e2
@ -243,7 +243,7 @@ There are three available options: `full`, `wide`, and `normal`. By default, the
|
|||||||
|
|
||||||
Similarly, the width of the navbar and footer can be customized by the `params.navbar.width` and `params.footer.width` parameters.
|
Similarly, the width of the navbar and footer can be customized by the `params.navbar.width` and `params.footer.width` parameters.
|
||||||
|
|
||||||
### Search Index
|
### FlexSearch Index
|
||||||
|
|
||||||
Full-text search powered by [FlexSearch](https://github.com/nextapps-de/flexsearch) is enabled by default.
|
Full-text search powered by [FlexSearch](https://github.com/nextapps-de/flexsearch) is enabled by default.
|
||||||
To customize the search index, set the `params.search.flexsearch.index` parameter in the config file:
|
To customize the search index, set the `params.search.flexsearch.index` parameter in the config file:
|
||||||
@ -284,7 +284,7 @@ Options for [`flexsearch.tokenize`](https://github.com/nextapps-de/flexsearch/#t
|
|||||||
- `reverse` - incrementally index words in both directions
|
- `reverse` - incrementally index words in both directions
|
||||||
- `full` - index every possible combination
|
- `full` - index every possible combination
|
||||||
|
|
||||||
To exclude a page from the search index, set the `excludeSearch: true` in the front matter of the page:
|
To exclude a page from the FlexSearch search index, set the `excludeSearch: true` in the front matter of the page:
|
||||||
|
|
||||||
```yaml {filename="content/docs/guide/configuration.md"}
|
```yaml {filename="content/docs/guide/configuration.md"}
|
||||||
---
|
---
|
||||||
@ -302,3 +302,20 @@ services:
|
|||||||
googleAnalytics:
|
googleAnalytics:
|
||||||
ID: G-MEASUREMENT_ID
|
ID: G-MEASUREMENT_ID
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Google Search Index
|
||||||
|
|
||||||
|
To [block Google Search](https://developers.google.com/search/docs/crawling-indexing/block-indexing) from indexing a page, set `noindex` to true in your page frontmatter:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
title: Configuration (archive version)
|
||||||
|
params:
|
||||||
|
noindex: true
|
||||||
|
```
|
||||||
|
|
||||||
|
To exclude an entire directory, use the [`cascade`](https://gohugo.io/configuration/cascade/) key in the parent `_index.md` file.
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> To block search crawlers, you can make a [`robots.txt` template](https://gohugo.io/templates/robots/).
|
||||||
|
> However, `robots.txt` instructions do not necessarily keep a page out of Google search results.
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
{{ if hugo.IsProduction -}}
|
{{- $noindex := .Params.noindex | default false -}}
|
||||||
|
{{ if and (hugo.IsProduction) (not $noindex) -}}
|
||||||
<meta name="robots" content="index, follow" />
|
<meta name="robots" content="index, follow" />
|
||||||
{{ else -}}
|
{{ else -}}
|
||||||
<meta name="robots" content="noindex, nofollow" />
|
<meta name="robots" content="noindex, nofollow" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user