From 6b5ed88cdeeed8a35265c8613f39697b8db32e51 Mon Sep 17 00:00:00 2001 From: Rick Cogley Date: Tue, 12 May 2015 15:56:56 +0900 Subject: 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. --- docs/content/extras/aliases.md | 70 +++++++++++++++++++++++++------------- docs/content/extras/comments.md | 35 ++++++++----------- docs/content/themes/customizing.md | 61 ++++++++++++++++----------------- 3 files changed, 89 insertions(+), 77 deletions(-) diff --git a/docs/content/extras/aliases.md b/docs/content/extras/aliases.md index adc7dc5da..830e81ef8 100644 --- a/docs/content/extras/aliases.md +++ b/docs/content/extras/aliases.md @@ -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** - - - - - - - - - - - - - -
TOMLYAML
+++
+
+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"
 ]
+        ...
 +++
-
---
+~~~
+
+### YAML frontmatter
+
+~~~yaml
+---
+        ...
 aliases:
     - /posts/my-original-url/
-    - /2010/even-earlier-url.html
+    - /2010/01/01/even-earlier-url.html
+        ...
 ---
-
+~~~ -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 + + + + + + + + +~~~ + +The `http-equiv="refresh"` line is what performs the redirect, in 0 seconds in this case. diff --git a/docs/content/extras/comments.md b/docs/content/extras/comments.md index 713f6fb5f..6be5ade44 100644 --- a/docs/content/extras/comments.md +++ b/docs/content/extras/comments.md @@ -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