mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-29 22:29:56 +02:00
Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65'
This commit is contained in:
@@ -1,33 +1,21 @@
|
||||
---
|
||||
title: Embedded templates
|
||||
description: Hugo provides embedded templates for common use cases.
|
||||
categories: [templates]
|
||||
categories: []
|
||||
keywords: []
|
||||
menu:
|
||||
docs:
|
||||
parent: templates
|
||||
weight: 200
|
||||
weight: 200
|
||||
toc: true
|
||||
weight: 170
|
||||
aliases: [/templates/internal]
|
||||
---
|
||||
|
||||
## Disqus
|
||||
|
||||
{{% note %}}
|
||||
To override Hugo's embedded Disqus template, copy the [source code] to a file with the same name in the `layouts/partials` directory, then call it from your templates using the [`partial`] function:
|
||||
|
||||
`{{ partial "disqus.html" . }}`
|
||||
|
||||
[`partial`]: /functions/partials/include/
|
||||
[source code]: {{% eturl disqus %}}
|
||||
{{% /note %}}
|
||||
> [!note]
|
||||
> To override Hugo's embedded Disqus template, copy the [source code]({{% eturl disqus %}}) to a file with the same name in the `layouts/partials` directory, then call it from your templates using the [`partial`] function:
|
||||
>
|
||||
> `{{ partial "disqus.html" . }}`
|
||||
|
||||
Hugo includes an embedded template for [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.
|
||||
|
||||
[Disqus]: https://disqus.com
|
||||
[signing up]: https://disqus.com/profile/signup/
|
||||
|
||||
To include the embedded template:
|
||||
|
||||
```go-html-template
|
||||
@@ -38,7 +26,7 @@ To include the embedded template:
|
||||
|
||||
To use Hugo's Disqus template, first set up a single configuration value:
|
||||
|
||||
{{< code-toggle file="hugo" >}}
|
||||
{{< code-toggle file=hugo >}}
|
||||
[services.disqus]
|
||||
shortname = 'your-disqus-shortname'
|
||||
{{</ code-toggle >}}
|
||||
@@ -66,19 +54,13 @@ disable
|
||||
|
||||
## Google Analytics
|
||||
|
||||
{{% note %}}
|
||||
To override Hugo's embedded Google Analytics template, copy the [source code] to a file with the same name in the `layouts/partials` directory, then call it from your templates using the [`partial`] function:
|
||||
|
||||
`{{ partial "google_analytics.html" . }}`
|
||||
|
||||
[`partial`]: /functions/partials/include/
|
||||
[source code]: {{% eturl google_analytics %}}
|
||||
{{% /note %}}
|
||||
> [!note]
|
||||
> To override Hugo's embedded Google Analytics template, copy the [source code]({{% eturl google_analytics %}}) to a file with the same name in the `layouts/partials` directory, then call it from your templates using the [`partial`] function:
|
||||
>
|
||||
> `{{ partial "google_analytics.html" . }}`
|
||||
|
||||
Hugo includes an embedded template supporting [Google Analytics 4].
|
||||
|
||||
[Google Analytics 4]: https://support.google.com/analytics/answer/10089681
|
||||
|
||||
To include the embedded template:
|
||||
|
||||
```go-html-template
|
||||
@@ -110,14 +92,10 @@ respectDoNotTrack
|
||||
|
||||
## Open Graph
|
||||
|
||||
{{% note %}}
|
||||
To override Hugo's embedded Open Graph template, copy the [source code] to a file with the same name in the `layouts/partials` directory, then call it from your templates using the [`partial`] function:
|
||||
|
||||
`{{ partial "opengraph.html" . }}`
|
||||
|
||||
[`partial`]: /functions/partials/include/
|
||||
[source code]: {{% eturl opengraph %}}
|
||||
{{% /note %}}
|
||||
> [!note]
|
||||
> To override Hugo's embedded Open Graph template, copy the [source code]({{% eturl opengraph %}}) to a file with the same name in the `layouts/partials` directory, then call it from your templates using the [`partial`] function:
|
||||
>
|
||||
> `{{ partial "opengraph.html" . }}`
|
||||
|
||||
Hugo includes an embedded template for the [Open Graph protocol](https://ogp.me/), metadata that enables a page to become a rich object in a social graph.
|
||||
This format is used for Facebook and some other sites.
|
||||
@@ -169,19 +147,13 @@ If using YouTube this will produce a og:video tag like `<meta property="og:video
|
||||
|
||||
## Schema
|
||||
|
||||
{{% note %}}
|
||||
To override Hugo's embedded Schema template, copy the [source code] to a file with the same name in the `layouts/partials` directory, then call it from your templates using the [`partial`] function:
|
||||
|
||||
`{{ partial "schema.html" . }}`
|
||||
|
||||
[`partial`]: /functions/partials/include/
|
||||
[source code]: {{% eturl schema %}}
|
||||
{{% /note %}}
|
||||
> [!note]
|
||||
> To override Hugo's embedded Schema template, copy the [source code]({{% eturl schema %}}) to a file with the same name in the `layouts/partials` directory, then call it from your templates using the [`partial`] function:
|
||||
>
|
||||
> `{{ partial "schema.html" . }}`
|
||||
|
||||
Hugo includes an embedded template to render [microdata] `meta` elements within the `head` element of your templates.
|
||||
|
||||
[microdata]: https://html.spec.whatwg.org/multipage/microdata.html#microdata
|
||||
|
||||
To include the embedded template:
|
||||
|
||||
```go-html-template
|
||||
@@ -190,14 +162,10 @@ To include the embedded template:
|
||||
|
||||
## X (Twitter) Cards
|
||||
|
||||
{{% note %}}
|
||||
To override Hugo's embedded Twitter Cards template, copy the [source code] to a file with the same name in the `layouts/partials` directory, then call it from your templates using the [`partial`] function:
|
||||
|
||||
`{{ partial "twitter_cards.html" . }}`
|
||||
|
||||
[`partial`]: /functions/partials/include/
|
||||
[source code]: {{% eturl twitter_cards %}}
|
||||
{{% /note %}}
|
||||
> [!note]
|
||||
> To override Hugo's embedded Twitter Cards template, copy the [source code]({{% eturl twitter_cards %}}) to a file with the same name in the `layouts/partials` directory, then call it from your templates using the [`partial`] function:
|
||||
>
|
||||
> `{{ partial "twitter_cards.html" . }}`
|
||||
|
||||
Hugo includes an embedded template for [X (Twitter) Cards](https://developer.x.com/en/docs/twitter-for-websites/cards/overview/abouts-cards),
|
||||
metadata used to attach rich media to Tweets linking to your site.
|
||||
@@ -218,21 +186,21 @@ Hugo's X (Twitter) Card template is configured using a mix of configuration sett
|
||||
description = "Text about my cool site"
|
||||
{{</ code-toggle >}}
|
||||
|
||||
{{< code-toggle file=content/blog/my-post.md >}}
|
||||
{{< code-toggle file=content/blog/my-post.md fm=true >}}
|
||||
title = "Post title"
|
||||
description = "Text about this post"
|
||||
images = ["post-cover.png"]
|
||||
{{</ code-toggle >}}
|
||||
|
||||
If [page bundles](/content-management/page-bundles/) are used and the `images` array is empty or undefined, images with file names matching `*feature*`, `*cover*`, or `*thumbnail*` are used for image metadata.
|
||||
If no image resources with those names are found, the images defined in the [site config](/getting-started/configuration/) are used instead.
|
||||
If no image resources with those names are found, the images defined in the [site config](/configuration/) are used instead.
|
||||
If no images are found at all, then an image-less Twitter `summary` card is used instead of `summary_large_image`.
|
||||
|
||||
Hugo uses the page title and description for the card's title and description fields. The page summary is used if no description is given.
|
||||
|
||||
Set the value of `twitter:site` in your site configuration:
|
||||
|
||||
{{< code-toggle file="hugo" copy=false >}}
|
||||
{{< code-toggle file=hugo >}}
|
||||
[params.social]
|
||||
twitter = "GoHugoIO"
|
||||
{{</ code-toggle >}}
|
||||
@@ -242,3 +210,9 @@ NOTE: The `@` will be added for you
|
||||
```html
|
||||
<meta name="twitter:site" content="@GoHugoIO"/>
|
||||
```
|
||||
|
||||
[`partial`]: /functions/partials/include/
|
||||
[Disqus]: https://disqus.com
|
||||
[Google Analytics 4]: https://support.google.com/analytics/answer/10089681
|
||||
[microdata]: https://html.spec.whatwg.org/multipage/microdata.html#microdata
|
||||
[signing up]: https://disqus.com/profile/signup/
|
||||
|
Reference in New Issue
Block a user