diff --git a/content/content-management/table-of-contents.md b/content/content-management/table-of-contents.md index 153590317..8e9951bb3 100644 --- a/content/content-management/table-of-contents.md +++ b/content/content-management/table-of-contents.md @@ -12,7 +12,6 @@ draft: false aliases: [/extras/toc/] toc: false needsreview: true -notesforauthors: --- Hugo will automatically parse the Markdown for your content and create diff --git a/content/templates/partial-templates.md b/content/templates/partial-templates.md index 03d0a59ec..1e5ceb615 100644 --- a/content/templates/partial-templates.md +++ b/content/templates/partial-templates.md @@ -10,7 +10,7 @@ categories: [templates] tags: [lists,sections,partials] draft: false slug: -aliases: [/templates/partials/,/layout/chrome/] +aliases: [/templates/partials/,/layout/chrome/,/extras/analytics/,/extras/comments/] toc: true notesforauthors: --- @@ -152,4 +152,106 @@ They are only use to create a unique cache key. ## Built-in Partials * Google Analytics -* Disqus Comments +Hugo ships with prebuilt internal templates for Google Analytics tracking, including both synchronous and asynchronous tracking codes. + + + +## Configuring Google Analytics + +Provide your tracking id in your configuration file, e.g. config.yaml. + + googleAnalytics = "UA-123-45" + +## Example + +Include the internal template in your templates like so: + + {{ template "_internal/google_analytics.html" . }} + +For async include the async template: + + {{ template "_internal/google_analytics_async.html" . }} + + + +As Hugo is a static site generator, the content produced is static and doesn’t interact with the users. The most common interaction people ask for is comment capability. + +Hugo ships with support for [Disqus](https://disqus.com/), a third-party service that provides comment and community capabilities to website via JavaScript. + +Your theme may already support Disqus, but even it if doesn’t, it is easy to add. + +# Disqus Support + +## Adding Disqus to a template + +Hugo comes with all the code you would need to include load Disqus. Simply include the following line where you want your comments to appear: + + {{ template "_internal/disqus.html" . }} + +## Configuring Disqus + +That template requires you to set a single value in your site config file, e.g. config.yaml. + + disqusShortname = "XYW" + +Additionally, you can optionally set the following in the front matter +for a given piece of content: + + * **disqus_identifier** + * **disqus_title** + * **disqus_url** + +## Conditional Loading of Disqus Comments + +Users have noticed that enabling Disqus comments when running the Hugo web server on localhost causes the creation of unwanted discussions on the associated Disqus account. In order to prevent this, a slightly tweaked partial template is required. So, rather than using the built-in `"_internal/disqus.html"` template referenced above, create a template in your `partials` folder that looks like this: + +```html +
+ + +comments powered by Disqus +``` + +Notice that there is a simple `if` statement that detects when you are running on localhost and skips the initialization of the Disqus comment injection. + +Now, reference the partial template from your page template: + + {{ partial "disqus.html" . }} + + +# Alternatives + +A few alternatives exist to [Disqus](https://disqus.com/): + +* [Discourse](http://www.discourse.org) +* [IntenseDebate](http://intensedebate.com/) +* [Livefyre](http://livefyre.com/) +* [Muut](http://muut.com/) +* [多说](http://duoshuo.com/) ([Duoshuo](http://duoshuo.com/), popular in China) +* [isso](http://posativ.org/isso/) (Self-hosted, Python) +* [Kaiju](https://github.com/spf13/kaiju) + +## Kaiju + +[Kaiju](https://github.com/spf13/kaiju) is an open-source project started by [spf13](http://spf13.com/) (Hugo’s author) to bring easy and fast real time discussions to the web. + +Written using Go, Socket.io and MongoDB, it is very fast and easy to deploy. + +It is in early development but shows promise. If you have interest, please help by contributing whether via a pull request, an issue or even just a tweet. Everything helps. + +## Discourse + +Additionally, you may recognize [Discourse](http://www.discourse.org) as the system that powers the [Hugo Discussion Forum](http://discuss.gohugo.io).