mirror of
https://github.com/gohugoio/hugo.git
synced 2025-09-01 22:42:45 +02:00
Merge commit '7c62d6ef1654c0383eae474d3bd9ddf7754c1f30'
This commit is contained in:
@@ -40,7 +40,7 @@ The following is an example of a homepage template that uses [partial][partials]
|
||||
<header class="homepage-header">
|
||||
<h1>{{ .Title }}</h1>
|
||||
{{ with .Params.subtitle }}
|
||||
<span class="subtitle">{{ . }}</span>
|
||||
<span class="subtitle">{{ . }}</span>
|
||||
{{ end }}
|
||||
</header>
|
||||
<div class="homepage-content">
|
||||
@@ -49,7 +49,7 @@ The following is an example of a homepage template that uses [partial][partials]
|
||||
</div>
|
||||
<div>
|
||||
{{ range first 10 .Site.RegularPages }}
|
||||
{{ .Render "summary" }}
|
||||
{{ .Render "summary" }}
|
||||
{{ end }}
|
||||
</div>
|
||||
</main>
|
||||
|
@@ -19,12 +19,12 @@ While the following internal templates are called similar to partials, they do *
|
||||
|
||||
## Google Analytics
|
||||
|
||||
Hugo ships with internal templates supporting Google Analytics, both [Google Analytics 4][GA4] (GA4) and Universal Analytics.
|
||||
Hugo ships with an internal template supporting [Google Analytics 4][GA4] (GA4).
|
||||
|
||||
**Note:** Universal Analytics are deprecated. For details, see [Universal Analytics will be going away].
|
||||
**Note:** Universal Analytics are [deprecated].
|
||||
|
||||
[GA4]: https://support.google.com/analytics/answer/10089681
|
||||
[Universal Analytics will be going away]: https://support.google.com/analytics/answer/11583528
|
||||
[deprecated]: https://support.google.com/analytics/answer/11583528
|
||||
|
||||
### Configure Google Analytics
|
||||
|
||||
@@ -35,40 +35,29 @@ Provide your tracking ID in your configuration file:
|
||||
googleAnalytics = "G-MEASUREMENT_ID"
|
||||
{{</ code-toggle >}}
|
||||
|
||||
**Google Universal Analytics (analytics.js)**
|
||||
{{< code-toggle file="hugo" >}}
|
||||
googleAnalytics = "UA-PROPERTY_ID"
|
||||
{{</ code-toggle >}}
|
||||
|
||||
### Use the Google Analytics template
|
||||
|
||||
You can then include the Google Analytics internal template:
|
||||
|
||||
```go-html-template
|
||||
{{ template "_internal/google_analytics_async.html" . }}
|
||||
```
|
||||
|
||||
**Note:** The async template is _not_ suitable for Google Analytics 4.
|
||||
Include the Google Analytics internal template in your templates where you want the code to appear:
|
||||
|
||||
```go-html-template
|
||||
{{ template "_internal/google_analytics.html" . }}
|
||||
```
|
||||
|
||||
If you want to create your own template, you can access the configured ID with `{{ site.Config.Services.GoogleAnalytics.ID }}`.
|
||||
To create your own template, access the configured ID with `{{ site.Config.Services.GoogleAnalytics.ID }}`.
|
||||
|
||||
## Disqus
|
||||
|
||||
Hugo also ships with an internal template for [Disqus comments][disqus], a popular commenting system for both static and dynamic websites. In order to effectively use Disqus, you will need to secure a Disqus "shortname" by [signing up for the free service][disqussignup].
|
||||
Hugo also ships with an internal template for [Disqus comments][disqus], a popular commenting system for both static and dynamic websites. To effectively use Disqus, secure a Disqus "shortname" by [signing up for the free service][disqussignup].
|
||||
|
||||
### Configure Disqus
|
||||
|
||||
To use Hugo's Disqus template, you first need to set a single configuration value:
|
||||
To use Hugo's Disqus template, first set up a single configuration value:
|
||||
|
||||
{{< code-toggle file="hugo" >}}
|
||||
disqusShortname = "your-disqus-shortname"
|
||||
{{</ code-toggle >}}
|
||||
|
||||
You also have the option to set the following in the front matter for a given piece of content:
|
||||
You can also set the following in the front matter for a given piece of content:
|
||||
|
||||
* `disqus_identifier`
|
||||
* `disqus_title`
|
||||
@@ -76,7 +65,7 @@ You also have the option to set the following in the front matter for a given pi
|
||||
|
||||
### Use the Disqus template
|
||||
|
||||
To add Disqus, include the following line in templates where you want your comments to appear:
|
||||
To add Disqus, include the following line in the templates where you want your comments to appear:
|
||||
|
||||
```go-html-template
|
||||
{{ template "_internal/disqus.html" . }}
|
||||
@@ -222,7 +211,6 @@ The code for these templates is located [here](https://github.com/gohugoio/hugo/
|
||||
|
||||
* `_internal/disqus.html`
|
||||
* `_internal/google_analytics.html`
|
||||
* `_internal/google_analytics_async.html`
|
||||
* `_internal/opengraph.html`
|
||||
* `_internal/pagination.html`
|
||||
* `_internal/schema.html`
|
||||
|
@@ -166,13 +166,13 @@ This list template has been modified slightly from a template originally used in
|
||||
{{ partial "subheader.html" . }}
|
||||
<main>
|
||||
<div>
|
||||
<h1>{{ .Title }}</h1>
|
||||
<ul>
|
||||
<!-- Renders the li.html content view for each content/posts/*.md -->
|
||||
{{ range .Pages }}
|
||||
{{ .Render "li" }}
|
||||
{{ end }}
|
||||
</ul>
|
||||
<h1>{{ .Title }}</h1>
|
||||
<ul>
|
||||
<!-- Renders the li.html content view for each content/posts/*.md -->
|
||||
{{ range .Pages }}
|
||||
{{ .Render "li" }}
|
||||
{{ end }}
|
||||
</ul>
|
||||
</div>
|
||||
</main>
|
||||
{{ partial "footer.html" . }}
|
||||
@@ -184,10 +184,10 @@ This list template has been modified slightly from a template originally used in
|
||||
{{ define "main" }}
|
||||
<main>
|
||||
<div>
|
||||
<h1>{{ .Title }}</h1>
|
||||
<!-- ranges through each of the content files associated with a particular taxonomy term and renders the summary.html content view -->
|
||||
<h1>{{ .Title }}</h1>
|
||||
<!-- ranges through each of the content files associated with a particular taxonomy term and renders the summary.html content view -->
|
||||
{{ range .Pages }}
|
||||
{{ .Render "summary" }}
|
||||
{{ .Render "summary" }}
|
||||
{{ end }}
|
||||
</div>
|
||||
</main>
|
||||
|
@@ -46,17 +46,17 @@ Examples:
|
||||
{{< code file="layouts/_default/section.html" >}}
|
||||
{{ define "main" }}
|
||||
<main>
|
||||
{{ .Content }}
|
||||
<ul class="contents">
|
||||
{{ range .Paginator.Pages }}
|
||||
<li>{{ .Title }}
|
||||
<div>
|
||||
{{ partial "summary.html" . }}
|
||||
</div>
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ partial "pagination.html" . }}
|
||||
{{ .Content }}
|
||||
<ul class="contents">
|
||||
{{ range .Paginator.Pages }}
|
||||
<li>{{ .Title }}
|
||||
<div>
|
||||
{{ partial "summary.html" . }}
|
||||
</div>
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ partial "pagination.html" . }}
|
||||
</main>
|
||||
{{ end }}
|
||||
{{< /code >}}
|
||||
|
@@ -94,7 +94,13 @@ most helpful when the condition depends on either of the values, or both:
|
||||
|
||||
#### `.Inner`
|
||||
|
||||
If a closing shortcode is used, the `.Inner` variable will be populated with the content between the opening and closing shortcodes. If a closing shortcode is required, you can check the length of `.Inner` as an indicator of its existence.
|
||||
If a closing shortcode is used, the `.Inner` variable will be populated with the content between the opening and closing shortcodes. To check if `.Inner` contains anything other than white space:
|
||||
|
||||
```go-html-template
|
||||
{{ if strings.ContainsNonSpace .Inner }}
|
||||
Inner is not empty
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
A shortcode with content declared via the `.Inner` variable can also be declared without the content and without the closing tag by using the self-closing syntax:
|
||||
|
||||
|
@@ -36,10 +36,10 @@ This single page template makes use of Hugo [base templates], the [`.Format` fun
|
||||
</section>
|
||||
<aside id="meta">
|
||||
<div>
|
||||
<section>
|
||||
<h4 id="date"> {{ .Date.Format "Mon Jan 2, 2006" }} </h4>
|
||||
<h5 id="wordcount"> {{ .WordCount }} Words </h5>
|
||||
</section>
|
||||
<section>
|
||||
<h4 id="date"> {{ .Date.Format "Mon Jan 2, 2006" }} </h4>
|
||||
<h5 id="wordcount"> {{ .WordCount }} Words </h5>
|
||||
</section>
|
||||
{{ with .GetTerms "topics" }}
|
||||
<ul id="topics">
|
||||
{{ range . }}
|
||||
|
Reference in New Issue
Block a user