Add option to exclude pages from sitemap

pull/2/head
James Panther 2021-08-15 10:37:48 +10:00
parent 60a0d89dde
commit 73218ce192
No known key found for this signature in database
GPG Key ID: D36F789E45745D17
4 changed files with 37 additions and 4 deletions

View File

@ -45,6 +45,8 @@ Congo is designed to be a fast, lightweight theme for Hugo. It's based upon Tail
- [Configuration](#configuration)
- [Getting started](#getting-started)
- [Organising content](#organising-content)
- [Parameters](#parameters)
- [Front Matter](#front-matter)
- [Shortcodes](#shortcodes)
- [Alert](#alert)
- [Icon](#icon)
@ -147,7 +149,9 @@ It's also useful to set the author configuration in the `config/_default/author.
[author]
name = "Your name"
twitter = "https://twitter.com/username"
links = [
{ twitter = "https://twitter.com/username" }
]
```
### Organising content
@ -182,6 +186,32 @@ When you create a new taxonomy, you will need to adjust the navigation links on
weight = 20
```
### Parameters
Congo provides a large number of configuration parameters that control how the theme functions. The table below outlines every available parameter in the `config/_default/params.toml` file.
<!-- prettier-ignore-start -->
|Name|Type|Default|Description|
| --- | --- | --- | --- |
|`article.showDate`|boolean|`true`|Whether or not the article date is displayed.|
|`article.dateFormat`|string|`"2 January 2006"`|How the article date is formatted. Refer to the [Hugo docs](https://gohugo.io/functions/format/#gos-layout-string) for acceptable formats.|
|`article.showReadingTime`|boolean|`true`|Whether or not reading time is displayed.|
|`article.showAuthor`|boolean|`true`|Whether or not the author box is displayed in the article footer.|
|`article.showPagination`|boolean|`true`|Whether or not the next/previous article links are displayed in the article footer.|
|`taxonomy.showTermCount`|boolean|`true`|Whether or not the number of articles within a taxonomy term is displayed on the taxonomy listing.|
|`sitemap.excludedKinds`|array of strings|`["taxonomy", "term"]`|Kinds of content that should be excluded from the generated `sitemap.xml` file. Refer to the [Hugo docs](https://gohugo.io/templates/section-templates/#page-kinds) for acceptable values.|
<!-- prettier-ignore-end -->
## Front Matter
In addition to the default Hugo front matter parameters, Congo adds a number of additional options to customise the presentation of individual articles. All the available theme parameters are listed below. Keep in mind that you only need to specify these parameters in your front matter when you want to override the default.
<!-- prettier-ignore-start -->
|Name|Type|Default|Description|
| --- | --- | --- | --- |
|`xml`|boolean|`true`|Whether or not this article is included in the generated sitemap.xml file.|
<!-- prettier-ignore-end -->
## Shortcodes
In addition to all the [default Hugo shortcodes](https://gohugo.io/content-management/shortcodes/), Congo adds a few extras for additional functionality.

View File

@ -12,6 +12,9 @@
[taxonomy]
showTermCount = true
[sitemap]
excludedKinds = ["taxonomy", "term"]
# -- Site Verification --
# Provide the verification strings for the providers below and the
# corresponding meta tags will be added to the site <head>.

View File

@ -4,6 +4,7 @@ date: "2019-03-09"
draft: true
description: "Lorem Ipsum Dolor Si Amet"
tags: ["markdown", "text"]
xml: false
---
Lorem est tota propiore conpellat pectoribus de pectora summo. <!--more-->Redit teque digerit hominumque toris verebor lumina non cervice subde tollit usus habet Arctonque, furores quas nec ferunt. Quoque montibus nunc caluere tempus inhospita parcite confusaque translucet patri vestro qui optatis lumine cognoscere flos nubis! Fronde ipsamque patulos Dryopen deorum.

View File

@ -1,10 +1,9 @@
{{ printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
{{ $excludedKinds := slice "taxonomy" "term" }}
{{ range .Data.Pages }}
{{ if not (in $excludedKinds .Kind) }}
{{ if not (isset .Params "externalurl") }}
{{ if not (in .Site.Params.sitemap.excludedKinds .Kind) }}
{{ if and (.Param "xml" | default true) (not (isset .Params "externalurl")) }}
{{- if .Permalink -}}
<url>
<loc>{{ .Permalink }}</loc>{{ if not .Lastmod.IsZero }}