diff options
author | Joe Mooring <[email protected]> | 2023-10-16 10:56:37 -0700 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2023-10-18 17:35:54 +0200 |
commit | 2eca1b3cc1cd03fee40c0abcdc61dab1016c0475 (patch) | |
tree | 444e59b4de1a36e993271c036655a291490ed443 /docs/content | |
parent | 625162674dbd6a32e86fb7fe1f91fafb4615d91b (diff) | |
download | hugo-2eca1b3cc1cd03fee40c0abcdc61dab1016c0475.tar.gz hugo-2eca1b3cc1cd03fee40c0abcdc61dab1016c0475.zip |
hugolib: Deprecate .Site.DisqusShortname
Use .Site.Config.Services.Disqus.Shortname instead.
Diffstat (limited to 'docs/content')
-rw-r--r-- | docs/content/en/content-management/comments.md | 5 | ||||
-rw-r--r-- | docs/content/en/templates/internal.md | 13 | ||||
-rw-r--r-- | docs/content/en/variables/site.md | 3 |
3 files changed, 12 insertions, 9 deletions
diff --git a/docs/content/en/content-management/comments.md b/docs/content/en/content-management/comments.md index df9453c48..39663013b 100644 --- a/docs/content/en/content-management/comments.md +++ b/docs/content/en/content-management/comments.md @@ -24,8 +24,9 @@ Hugo comes with all the code you need to load Disqus into your templates. Before Disqus comments require you set a single value in your [site's configuration file][configuration] like so: -{{< code-toggle copy=false >}} -disqusShortname = "yourDisqusShortname" +{{< code-toggle file="hugo" >}} +[services.disqus] +shortname = 'your-disqus-shortname' {{</ code-toggle >}} For many websites, this is enough configuration. However, you also have the option to set the following in the [front matter] of a single content file: diff --git a/docs/content/en/templates/internal.md b/docs/content/en/templates/internal.md index 52e846007..9118184e8 100644 --- a/docs/content/en/templates/internal.md +++ b/docs/content/en/templates/internal.md @@ -55,9 +55,16 @@ Hugo also ships with an internal template for [Disqus comments][disqus], a popul To use Hugo's Disqus template, first set up a single configuration value: {{< code-toggle file="hugo" >}} -disqusShortname = "your-disqus-shortname" +[services.disqus] +shortname = 'your-disqus-shortname' {{</ code-toggle >}} +Hugo's Disqus template accesses this value with: + +```go-html-template +{{ .Site.Config.Services.Disqus.Shortname }} +``` + You can also set the following in the front matter for a given piece of content: * `disqus_identifier` @@ -72,8 +79,6 @@ To add Disqus, include the following line in the templates where you want your c {{ template "_internal/disqus.html" . }} ``` -A `.Site.DisqusShortname` variable is also exposed from the configuration. - ### Conditional loading of Disqus comments Users have noticed that enabling Disqus comments when running the Hugo web server on `localhost` (i.e. via `hugo server`) causes the creation of unwanted discussions on the associated Disqus account. @@ -91,7 +96,7 @@ You can create the following `layouts/partials/disqus.html`: return; var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; - var disqus_shortname = '{{ .Site.DisqusShortname }}'; + var disqus_shortname = '{{ .Site.Config.Services.Disqus.Shortname }}'; dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })(); diff --git a/docs/content/en/variables/site.md b/docs/content/en/variables/site.md index 4605b9a42..55e9a7512 100644 --- a/docs/content/en/variables/site.md +++ b/docs/content/en/variables/site.md @@ -35,9 +35,6 @@ All the methods below, e.g. `.Site.RegularPages` can also be reached via the glo .Site.Data : custom data, see [Data Templates](/templates/data-templates/). -.Site.DisqusShortname -: a string representing the shortname of the Disqus shortcode as defined in the site configuration. - .Site.Home : reference to the homepage's [page object](/variables/page/) |