mirror of
https://github.com/gohugoio/hugo.git
synced 2024-05-11 05:54:58 +00:00
Edits on aliases, comments, theme customizing
Fleshed out aliases section, loading the "redirect" keyword so that it's easier to find. Specifically added a "how aliases work" section. Added Discourse to comments section. Fleshed out themes/customizing, because it seems to be the source of a lot of questions on the forum.
This commit is contained in:
@@ -13,41 +13,44 @@ title: Aliases
|
||||
weight: 10
|
||||
---
|
||||
|
||||
For people migrating existing published content to Hugo, there's a good chance
|
||||
you need a mechanism to handle redirecting old URLs.
|
||||
For people migrating existing published content to Hugo, there's a good chance you need a mechanism to handle redirecting old URLs.
|
||||
|
||||
Luckily, this can be handled easily with aliases in Hugo.
|
||||
Luckily, redirects can be handled easily with _aliases_ in Hugo.
|
||||
|
||||
## Example
|
||||
**content/posts/my-awesome-blog-post.md**
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>TOML</th><th>YAML</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr valign="top">
|
||||
<td><pre><code>+++
|
||||
Given a post on your current Hugo site, with a path of:
|
||||
|
||||
``content/posts/my-awesome-blog-post.md``
|
||||
|
||||
... you create an "aliases" section in the frontmatter of your post, and add previous paths to that.
|
||||
|
||||
### TOML frontmatter
|
||||
|
||||
~~~yaml
|
||||
+++
|
||||
...
|
||||
aliases = [
|
||||
"/posts/my-original-url/",
|
||||
"/2010/even-earlier-url.html"
|
||||
"/2010/01/01/even-earlier-url.html"
|
||||
]
|
||||
...
|
||||
+++
|
||||
</code></pre></td>
|
||||
<td><pre><code>---
|
||||
~~~
|
||||
|
||||
### YAML frontmatter
|
||||
|
||||
~~~yaml
|
||||
---
|
||||
...
|
||||
aliases:
|
||||
- /posts/my-original-url/
|
||||
- /2010/even-earlier-url.html
|
||||
- /2010/01/01/even-earlier-url.html
|
||||
...
|
||||
---
|
||||
</code></pre></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
~~~
|
||||
|
||||
Now when you go to any of the aliases locations, they
|
||||
will redirect to the page.
|
||||
Now when you visit any of the locations specified in aliases, _assuming the same site domain_, you'll be redirected to the page they are specified on.
|
||||
|
||||
## Important Behaviors
|
||||
|
||||
@@ -57,3 +60,22 @@ complete filename or directory.*
|
||||
|
||||
2. *Aliases are rendered prior to any content and will be overwritten by
|
||||
any content with the same location.*
|
||||
|
||||
## How Hugo Aliases Work
|
||||
|
||||
When aliases are specified, Hugo creates a physical folder structure to match the alias entry, and, an html file specifying the canonical URL for the page, and a redirect target.
|
||||
|
||||
Assuming a baseurl of `mysite.tld`, the contents of the html file will look something like:
|
||||
|
||||
~~~html
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="canonical" href="http://mysite.tld/posts/my-original-url"/>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
|
||||
<meta http-equiv="refresh" content="0;url=http://mysite.tld/posts/my-original-url"/>
|
||||
</head>
|
||||
</html>
|
||||
~~~
|
||||
|
||||
The `http-equiv="refresh"` line is what performs the redirect, in 0 seconds in this case.
|
||||
|
@@ -10,27 +10,20 @@ title: Comments in Hugo
|
||||
weight: 30
|
||||
---
|
||||
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
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:
|
||||
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.
|
||||
@@ -44,12 +37,11 @@ for a given piece of content:
|
||||
* **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:
|
||||
|
||||
```javascript
|
||||
```html
|
||||
<div id="disqus_thread"></div>
|
||||
<script type="text/javascript">
|
||||
|
||||
@@ -80,6 +72,7 @@ Now, reference the partial template from your page template:
|
||||
|
||||
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/)
|
||||
@@ -87,15 +80,15 @@ A few alternatives exist to [Disqus](https://disqus.com/):
|
||||
* [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.
|
||||
[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.
|
||||
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.
|
||||
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).
|
||||
|
||||
|
Reference in New Issue
Block a user