Docs: Add nohighlight shortcode and improve formatting

And some random formatting and copyediting fixes.

See also #1708
This commit is contained in:
Anthony Fok 2015-12-23 09:31:07 -07:00
parent 22bd485072
commit cb8f459127
15 changed files with 300 additions and 260 deletions

View file

@ -29,10 +29,12 @@ We will use tags and categories for our taxonomies, so let's create
#### archetypes/default.md #### archetypes/default.md
+++ ```toml
tags = ["x", "y"] +++
categories = ["x", "y"] tags = ["x", "y"]
+++ categories = ["x", "y"]
+++
```
> __CAVEAT:__ Some editors (e.g. Sublime, Emacs) do not insert an EOL (end-of-line) character at the end of the file (i.e. EOF). If you get a [strange EOF error](/troubleshooting/strange-eof-error/) when using `hugo new`, please open each archetype file (i.e.&nbsp;`archetypes/*.md`) and press <kbd>Enter</kbd> to type a carriage return after the closing `+++` or `---` as necessary. > __CAVEAT:__ Some editors (e.g. Sublime, Emacs) do not insert an EOL (end-of-line) character at the end of the file (i.e. EOF). If you get a [strange EOF error](/troubleshooting/strange-eof-error/) when using `hugo new`, please open each archetype file (i.e.&nbsp;`archetypes/*.md`) and press <kbd>Enter</kbd> to type a carriage return after the closing `+++` or `---` as necessary.
@ -47,12 +49,14 @@ Hugo would create the file with the following contents:
#### content/post/my-new-post.md #### content/post/my-new-post.md
+++ ```toml
title = "my new post" +++
date = "2015-01-12T19:20:04-07:00" title = "my new post"
tags = ["x", "y"] date = "2015-01-12T19:20:04-07:00"
categories = ["x", "y"] tags = ["x", "y"]
+++ categories = ["x", "y"]
+++
```
We see that the `title` and `date` variables have been added, in addition to the `tags` and `categories` variables which were carried over from `archetype/default.md`. We see that the `title` and `date` variables have been added, in addition to the `tags` and `categories` variables which were carried over from `archetype/default.md`.
@ -64,11 +68,13 @@ Earlier you created a new content type by adding a new subfolder to the content
#### archetypes/musician.md #### archetypes/musician.md
+++ ```toml
name = "" +++
bio = "" name = ""
genre = "" bio = ""
+++ genre = ""
+++
```
Now let's create a new musician. Now let's create a new musician.
@ -78,13 +84,15 @@ This time, Hugo recognizes the custom archetype and uses it instead of the defau
#### content/musician/mozart.md #### content/musician/mozart.md
+++ ```toml
title = "mozart" +++
date = "2015-08-24T13:04:37+02:00" title = "mozart"
name = "" date = "2015-08-24T13:04:37+02:00"
bio = "" name = ""
genre = "" bio = ""
+++ genre = ""
+++
```
## Using a different front matter format ## Using a different front matter format

View file

@ -6,9 +6,9 @@ linktitle: Example
menu: menu:
main: main:
parent: content parent: content
prev: /content/summaries
next: /themes/overview next: /themes/overview
notoc: true notoc: true
prev: /content/summaries
title: Example Content File title: Example Content File
weight: 70 weight: 70
--- ---
@ -19,8 +19,7 @@ Some things are better shown than explained. The following is a very basic examp
With TOML front matter: With TOML front matter:
```markdown <pre><code class="language-toml">+++
+++
date = "2013-06-21T11:27:27-04:00" date = "2013-06-21T11:27:27-04:00"
title = "Nitro: A quick and simple profiler for Go" title = "Nitro: A quick and simple profiler for Go"
description = "Nitro is a simple profiler for your Golang applications" description = "Nitro is a simple profiler for your Golang applications"
@ -29,8 +28,7 @@ topics = [ "Development", "Go" ]
slug = "nitro" slug = "nitro"
project_url = "https://github.com/spf13/nitro" project_url = "https://github.com/spf13/nitro"
+++ +++
</code><code class="language-markdown"># Nitro
# Nitro
Quick and easy performance analyzer library for [Go](http://golang.org/). Quick and easy performance analyzer library for [Go](http://golang.org/).
@ -48,11 +46,11 @@ of the library.
$ go get github.com/spf13/nitro $ go get github.com/spf13/nitro
Next, include nitro in your application. Next, include nitro in your application.
``` </code></pre>
You may also use the equivalent YAML front matter: You may also use the equivalent YAML front matter:
```markdown ```yaml
--- ---
date: "2013-06-21T11:27:27-04:00" date: "2013-06-21T11:27:27-04:00"
title: "Nitro: A quick and simple profiler for Go" title: "Nitro: A quick and simple profiler for Go"

View file

@ -28,50 +28,54 @@ Supported formats:
## TOML Example ## TOML Example
+++ <pre><code class="language-toml">+++
title = "spf13-vim 3.0 release and new website" title = "spf13-vim 3.0 release and new website"
description = "spf13-vim is a cross platform distribution of vim plugins and resources for Vim." description = "spf13-vim is a cross platform distribution of vim plugins and resources for Vim."
tags = [ ".vimrc", "plugins", "spf13-vim", "vim" ] tags = [ ".vimrc", "plugins", "spf13-vim", "vim" ]
date = "2012-04-06" date = "2012-04-06"
categories = [ categories = [
"Development", "Development",
"VIM" "VIM"
] ]
slug = "spf13-vim-3-0-release-and-new-website" slug = "spf13-vim-3-0-release-and-new-website"
+++ +++
</code><code class="language-markdown">Content of the file goes Here
Content of the file goes Here </code></pre>
## YAML Example ## YAML Example
--- ```yaml
title: "spf13-vim 3.0 release and new website" ---
description: "spf13-vim is a cross platform distribution of vim plugins and resources for Vim." title: "spf13-vim 3.0 release and new website"
tags: [ ".vimrc", "plugins", "spf13-vim", "vim" ] description: "spf13-vim is a cross platform distribution of vim plugins and resources for Vim."
date: "2012-04-06" tags: [ ".vimrc", "plugins", "spf13-vim", "vim" ]
categories: date: "2012-04-06"
- "Development" categories:
- "VIM" - "Development"
slug: "spf13-vim-3-0-release-and-new-website" - "VIM"
--- slug: "spf13-vim-3-0-release-and-new-website"
---
Content of the file goes Here
Content of the file goes Here
```
## JSON Example ## JSON Example
{ ```json
"title": "spf13-vim 3.0 release and new website", {
"description": "spf13-vim is a cross platform distribution of vim plugins and resources for Vim.", "title": "spf13-vim 3.0 release and new website",
"tags": [ ".vimrc", "plugins", "spf13-vim", "vim" ], "description": "spf13-vim is a cross platform distribution of vim plugins and resources for Vim.",
"date": "2012-04-06", "tags": [ ".vimrc", "plugins", "spf13-vim", "vim" ],
"categories": [ "date": "2012-04-06",
"Development", "categories": [
"VIM" "Development",
], "VIM"
"slug": "spf13-vim-3-0-release-and-new-website", ],
} "slug": "spf13-vim-3-0-release-and-new-website",
}
Content of the file goes Here
Content of the file goes Here
```
## Variables ## Variables

View file

@ -26,13 +26,14 @@ guaranteed.
## Assigning weight to content ## Assigning weight to content
+++ ```toml
weight = 4 +++
title = "Three" weight = 4
date = "2012-04-06" title = "Three"
+++ date = "2012-04-06"
Front Matter with Ordered Pages 3 +++
Front Matter with Ordered Pages 3
```
## Ordering Content Within Taxonomies ## Ordering Content Within Taxonomies

View file

@ -17,17 +17,17 @@ uses the top level of your content organization as **the Section**.
The following example site uses two sections, "post" and "quote". The following example site uses two sections, "post" and "quote".
. {{< nohighlight >}}.
└── content └── content
├── post ├── post
| ├── firstpost.md // <- http://1.com/post/firstpost/ | ├── firstpost.md // <- http://1.com/post/firstpost/
| ├── happy | ├── happy
| | └── ness.md // <- http://1.com/post/happy/ness/ | | └── ness.md // <- http://1.com/post/happy/ness/
| └── secondpost.md // <- http://1.com/post/secondpost/ | └── secondpost.md // <- http://1.com/post/secondpost/
└── quote └── quote
├── first.md // <- http://1.com/quote/first/ ├── first.md // <- http://1.com/quote/first/
└── second.md // <- http://1.com/quote/second/ └── second.md // <- http://1.com/quote/second/
{{< /nohighlight >}}
## Section Lists ## Section Lists

View file

@ -27,7 +27,7 @@ Given a post on your current Hugo site, with a path of:
### TOML frontmatter ### TOML frontmatter
~~~yaml ```toml
+++ +++
... ...
aliases = [ aliases = [
@ -36,11 +36,11 @@ aliases = [
] ]
... ...
+++ +++
~~~ ```
### YAML frontmatter ### YAML frontmatter
~~~yaml ```yaml
--- ---
... ...
aliases: aliases:
@ -48,15 +48,15 @@ aliases:
- /2010/01/01/even-earlier-url.html - /2010/01/01/even-earlier-url.html
... ...
--- ---
~~~ ```
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. 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 ## Important Behaviors
1. *Hugo makes no assumptions about aliases. They also don't change based 1. *Hugo makes no assumptions about aliases. They also don't change based
on your UglyURLs setting. You need to provide absolute path to your webroot and the on your UglyURLs setting. You need to provide absolute path to your webroot
complete filename or directory.* and the complete filename or directory.*
2. *Aliases are rendered prior to any content and will be overwritten by 2. *Aliases are rendered prior to any content and will be overwritten by
any content with the same location.* any content with the same location.*
@ -67,7 +67,7 @@ When aliases are specified, Hugo creates a physical folder structure to match th
Assuming a baseurl of `mysite.tld`, the contents of the html file will look something like: Assuming a baseurl of `mysite.tld`, the contents of the html file will look something like:
~~~html ```html
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
@ -76,6 +76,6 @@ Assuming a baseurl of `mysite.tld`, the contents of the html file will look some
<meta http-equiv="refresh" content="0;url=http://mysite.tld/posts/my-original-url"/> <meta http-equiv="refresh" content="0;url=http://mysite.tld/posts/my-original-url"/>
</head> </head>
</html> </html>
~~~ ```
The `http-equiv="refresh"` line is what performs the redirect, in 0 seconds in this case. The `http-equiv="refresh"` line is what performs the redirect, in 0 seconds in this case.

View file

@ -14,12 +14,14 @@ Hugo makes it easy to link documents together with the `ref` and `relref` shortc
## Using `ref` and `relref` ## Using `ref` and `relref`
{{</* ref "document" */>}} ```django
{{</* ref "#anchor" */>}} {{</* ref "document" */>}}
{{</* ref "document#anchor" */>}} {{</* ref "#anchor" */>}}
{{</* relref "document" */>}} {{</* ref "document#anchor" */>}}
{{</* relref "#anchor" */>}} {{</* relref "document" */>}}
{{</* relref "document#anchor" */>}} {{</* relref "#anchor" */>}}
{{</* relref "document#anchor" */>}}
```
The single parameter to `ref` is a string with a content _document name_ (`about.md`), an in-document _anchor_ (`#who`), or both (`about.md#who`). The single parameter to `ref` is a string with a content _document name_ (`about.md`), an in-document _anchor_ (`#who`), or both (`about.md#who`).

View file

@ -14,7 +14,7 @@ weight: 30
Make sure either `hugo` is in your `PATH` or provide a path to it. Make sure either `hugo` is in your `PATH` or provide a path to it.
<pre><code class="hljs nohighlight">$ hugo help {{< nohighlight >}}$ hugo help
Hugo is a Fast and Flexible Static Site Generator built with love by spf13 and friends in Go. Hugo is a Fast and Flexible Static Site Generator built with love by spf13 and friends in Go.
@ -65,20 +65,21 @@ Additional help topics:
hugo convert Convert will modify your content to different formats hugo list Listing out various types of content hugo convert Convert will modify your content to different formats hugo list Listing out various types of content
Use "hugo help [command]" for more information about a command. Use "hugo help [command]" for more information about a command.
</code></pre> {{< /nohighlight >}}
## Common Usage Example ## Common Usage Example
The most common use is probably to run `hugo` with your current directory being the input directory: The most common use is probably to run `hugo` with your current directory being the input directory:
$ hugo {{< nohighlight >}}$ hugo
0 draft content 0 draft content
0 future content 0 future content
99 pages created 99 pages created
0 paginator pages created 0 paginator pages created
16 tags created 16 tags created
0 groups created 0 groups created
in 120 ms in 120 ms
{{< /nohighlight >}}
This generates your web site to the `public/` directory, This generates your web site to the `public/` directory,
ready to be deployed to your web server. ready to be deployed to your web server.
@ -89,34 +90,36 @@ ready to be deployed to your web server.
If you are working on things and want to see the changes immediately, tell Hugo to watch for changes. If you are working on things and want to see the changes immediately, tell Hugo to watch for changes.
Hugo will watch the filesystem for changes, and rebuild your site as soon as a file is saved: Hugo will watch the filesystem for changes, and rebuild your site as soon as a file is saved:
$ hugo -s ~/Code/hugo/docs {{< nohighlight >}}$ hugo -s ~/Code/hugo/docs
0 draft content 0 draft content
0 future content 0 future content
99 pages created 99 pages created
0 paginator pages created 0 paginator pages created
16 tags created 16 tags created
0 groups created 0 groups created
in 120 ms in 120 ms
Watching for changes in /Users/spf13/Code/hugo/docs/content Watching for changes in /Users/spf13/Code/hugo/docs/content
Press Ctrl+C to stop Press Ctrl+C to stop
{{< /nohighlight >}}
Hugo can even run a server and create a site preview at the same time! Hugo can even run a server and create a site preview at the same time!
Hugo implements [LiveReload](/extras/livereload/) technology to automatically Hugo implements [LiveReload](/extras/livereload/) technology to automatically
reload any open pages in all JavaScript-enabled browsers, including mobile. reload any open pages in all JavaScript-enabled browsers, including mobile.
This is the easiest and most common way to develop a Hugo web site: This is the easiest and most common way to develop a Hugo web site:
$ hugo server -ws ~/Code/hugo/docs {{< nohighlight >}}$ hugo server -ws ~/Code/hugo/docs
0 draft content 0 draft content
0 future content 0 future content
99 pages created 99 pages created
0 paginator pages created 0 paginator pages created
16 tags created 16 tags created
0 groups created 0 groups created
in 120 ms in 120 ms
Watching for changes in /Users/spf13/Code/hugo/docs/content Watching for changes in /Users/spf13/Code/hugo/docs/content
Serving pages from /Users/spf13/Code/hugo/docs/public Serving pages from /Users/spf13/Code/hugo/docs/public
Web Server is available at http://localhost:1313/ Web Server is available at http://localhost:1313/
Press Ctrl+C to stop Press Ctrl+C to stop
{{< /nohighlight >}}
## Deploying your web site ## Deploying your web site
@ -151,11 +154,13 @@ An easy way to work around this is to use different directories for development
To start a server that builds draft content (helpful for editing), you can specify a different destination: the `dev/` dir. To start a server that builds draft content (helpful for editing), you can specify a different destination: the `dev/` dir.
$ hugo server -wDs ~/Code/hugo/docs -d dev {{< nohighlight >}}$ hugo server -wDs ~/Code/hugo/docs -d dev
{{< /nohighlight >}}
When the content is ready for publishing, use the default `public/` dir: When the content is ready for publishing, use the default `public/` dir:
$ hugo -s ~/Code/hugo/docs {{< nohighlight >}}$ hugo -s ~/Code/hugo/docs
{{< /nohighlight >}}
This prevents content you're not ready to share yet from accidentally becoming available. This prevents content you're not ready to share yet from accidentally becoming available.
@ -170,9 +175,11 @@ No other web server software (Apache, nginx, IIS...) is necessary.
Here is the command: Here is the command:
$ hugo server --baseURL=http://yoursite.org/ --port=80 \ {{< nohighlight >}}$ hugo server --baseURL=http://yoursite.org/ \
--appendPort=false \ --port=80 \
--bind=87.245.198.50 --appendPort=false \
--bind=87.245.198.50
{{< /nohighlight >}}
Note the `bind` option, which is the interface to which the server will bind (defaults to `127.0.0.1`, which is fine for most development use cases). Some hosts, like Amazon WS, runs network address translation and it can sometimes be hard to figure out the actual IP address. Using `--bind=0.0.0.0` will bind to all interfaces. Note the `bind` option, which is the interface to which the server will bind (defaults to `127.0.0.1`, which is fine for most development use cases). Some hosts, like Amazon WS, runs network address translation and it can sometimes be hard to figure out the actual IP address. Using `--bind=0.0.0.0` will bind to all interfaces.

View file

@ -16,39 +16,53 @@ Hugo makes a set of values and methods available on the various Taxonomy structu
A Taxonomy is a `map[string]WeightedPages`. A Taxonomy is a `map[string]WeightedPages`.
**.Get(term)** Returns the WeightedPages for a term. <br> .Get(term)
**.Count(term)** The number of pieces of content assigned to this term.<br> : Returns the WeightedPages for a term.
**.Alphabetical** Returns an OrderedTaxonomy (slice) ordered by Term. <br>
**.ByCount** Returns an OrderedTaxonomy (slice) ordered by number of entries. <br> .Count(term)
: The number of pieces of content assigned to this term.
.Alphabetical
: Returns an OrderedTaxonomy (slice) ordered by Term.
.ByCount
: Returns an OrderedTaxonomy (slice) ordered by number of entries.
## OrderedTaxonomy ## OrderedTaxonomy
Since Maps are unordered, an OrderedTaxonomy is a special structure that has a defined order. Since Maps are unordered, an OrderedTaxonomy is a special structure that has a defined order.
[]struct { ```go
Name string []struct {
WeightedPages WeightedPages Name string
} WeightedPages WeightedPages
}
```
Each element of the slice has: Each element of the slice has:
**.Term** The Term used.<br> .Term
**.WeightedPages** A slice of Weighted Pages.<br> : The Term used.
**.Count** The number of pieces of content assigned to this term.<br>
**.Pages** All Pages assigned to this term. All [list methods](/templates/list/) are available to this.<br> .WeightedPages
: A slice of Weighted Pages.
.Count
: The number of pieces of content assigned to this term.
.Pages
: All Pages assigned to this term. All [list methods](/templates/list/) are available to this.
## WeightedPages ## WeightedPages
WeightedPages is simply a slice of WeightedPage. WeightedPages is simply a slice of WeightedPage.
type WeightedPages []WeightedPage ```go
type WeightedPages []WeightedPage
**.Count(term)** The number of pieces of content assigned to this term.<br> ```
**.Pages** Returns a slice of pages, which then can be ordered using any of the [list methods](/templates/list/). <br>
.Count(term)
: The number of pieces of content assigned to this term.
.Pages
: Returns a slice of pages, which then can be ordered using any of the [list methods](/templates/list/).

View file

@ -57,15 +57,16 @@ When iterating over content within taxonomies the default sort is first by weigh
Content can be assigned weight for each taxonomy that it's assigned to. Content can be assigned weight for each taxonomy that it's assigned to.
+++ ```toml
tags = [ "a", "b", "c" ] +++
tags_weight = 22 tags = [ "a", "b", "c" ]
categories = ["d"] tags_weight = 22
title = "foo" categories = ["d"]
categories_weight = 44 title = "foo"
+++ categories_weight = 44
Front Matter with weighted tags and categories +++
Front Matter with weighted tags and categories
```
The convention is `taxonomyname_weight`. The convention is `taxonomyname_weight`.

View file

@ -30,10 +30,10 @@ or <code><strong>singular key</strong>: &quot;<em>plural value</em>&quot;</code>
</thead> </thead>
<tbody> <tbody>
<tr valign="top"> <tr valign="top">
<td><pre><code>[taxonomies] <td><pre><code class="language-toml">[taxonomies]
tag = "tags" tag = "tags"
category = "categories" category = "categories"
series = "series" series = "series"
</code></pre></td> </code></pre></td>
<td><pre><code class="language-yaml">taxonomies: <td><pre><code class="language-yaml">taxonomies:
tag: "tags" tag: "tags"
@ -69,31 +69,35 @@ you will need to pass the taxonomy values through the `urlize` template function
### Front Matter Example (in TOML) ### Front Matter Example (in TOML)
+++ ```toml
title = "Hugo: A fast and flexible static site generator" +++
tags = [ "Development", "Go", "fast", "Blogging" ] title = "Hugo: A fast and flexible static site generator"
categories = [ "Development" ] tags = [ "Development", "Go", "fast", "Blogging" ]
series = [ "Go Web Dev" ] categories = [ "Development" ]
slug = "hugo" series = [ "Go Web Dev" ]
project_url = "https://github.com/spf13/hugo" slug = "hugo"
+++ project_url = "https://github.com/spf13/hugo"
+++
```
### Front Matter Example (in JSON) ### Front Matter Example (in JSON)
{ ```json
"title": "Hugo: A fast and flexible static site generator", {
"tags": [ "title": "Hugo: A fast and flexible static site generator",
"Development", "tags": [
"Go", "Development",
"fast", "Go",
"Blogging" "fast",
], "Blogging"
"categories" : [ ],
"Development" "categories" : [
], "Development"
"series" : [ ],
"Go Web Dev" "series" : [
], "Go Web Dev"
"slug": "hugo", ],
"project_url": "https://github.com/spf13/hugo" "slug": "hugo",
} "project_url": "https://github.com/spf13/hugo"
}
```

View file

@ -51,8 +51,8 @@ e.g.
// Outputs Tags: tag1, tag2 and tag3 // Outputs Tags: tag1, tag2 and tag3
### dict ### dict
Creates a dictionary (map[string, interface{}), expects parameters added in value:object fasion. Creates a dictionary `(map[string, interface{})`, expects parameters added in value:object fasion.
Invalid combinations like keys that are not strings or uneven number of parameters, will result in an exception thrown Invalid combinations like keys that are not strings or uneven number of parameters, will result in an exception thrown.
Useful for passing maps to partials when adding to a template. Useful for passing maps to partials when adding to a template.
e.g. Pass into "foo.html" a map with the keys "important, content" e.g. Pass into "foo.html" a map with the keys "important, content"
@ -369,7 +369,7 @@ e.g., `{{chomp "<p>Blockhead</p>\n"}}` → `"<p>Blockhead</p>"`
Converts the textual representation of the datetime into the other form or returns it of Go `time.Time` type value. Converts the textual representation of the datetime into the other form or returns it of Go `time.Time` type value.
These are formatted with the layout string. These are formatted with the layout string.
e.g. `{{ dateFormat "Monday, Jan 2, 2006" "2015-01-21" }}` →"Wednesday, Jan 21, 2015" e.g. `{{ dateFormat "Monday, Jan 2, 2006" "2015-01-21" }}` "Wednesday, Jan 21, 2015"
### highlight ### highlight

View file

@ -54,31 +54,29 @@ Run a few commands to verify that the executable is ready to run and then build
2. At the prompt, type `hugo help` and press the Enter key. You should see output that starts with: 2. At the prompt, type `hugo help` and press the Enter key. You should see output that starts with:
<pre><code class="hljs no-highlight">A Fast and Flexible Static Site Generator built with love by spf13 and friends in Go. Complete documentation is available at http://gohugo.io {{< nohighlight >}}A Fast and Flexible Static Site Generator built with love by spf13 and friends in Go. Complete documentation is available at http://gohugo.io
</code></pre> {{< /nohighlight >}}
If you do, then the installation is complete. If you don't, double-check the path that you placed the `hugo.exe` file in and that you typed that path correctly when you added it to your PATH variable. If you're still not getting the output, post a note on the Hugo discussion list (in the `Support` topic) with your command and the output. If you do, then the installation is complete. If you don't, double-check the path that you placed the `hugo.exe` file in and that you typed that path correctly when you added it to your PATH variable. If you're still not getting the output, post a note on the Hugo discussion list (in the `Support` topic) with your command and the output.
3. At the prompt, change your directory to the `Sites` directory. 3. At the prompt, change your directory to the `Sites` directory.
``` {{< nohighlight >}}C:\Program Files> cd D:\Hugo\Sites
C:\Program Files> cd D:\Hugo\Sites
C:\Program Files> D: C:\Program Files> D:
D:\Hugo\Sites> D:\Hugo\Sites>
``` {{< /nohighlight >}}
4. Run the command to generate a new site. I'm using `example.com` as the name of the site. 4. Run the command to generate a new site. I'm using `example.com` as the name of the site.
``` {{< nohighlight >}}D:\Hugo\Sites> hugo new site example.com
D:\Hugo\Sites> hugo new site example.com {{< /nohighlight >}}
```
5. You should now have a directory at `D:\Hugo\Sites\example.com`. Change into that directory and list the contents. You should get output similar to the following: 5. You should now have a directory at `D:\Hugo\Sites\example.com`. Change into that directory and list the contents. You should get output similar to the following:
<pre><code class="hljs no-highlight">D:\Hugo\Sites&gt;cd example.com {{< nohighlight >}}D:\Hugo\Sites&gt;cd example.com
D:\Hugo\Sites\example.com&gt;dir D:\Hugo\Sites\example.com&gt;dir
&nbsp;Directory of D:\hugo\sites\example.com &nbsp;Directory of D:\hugo\sites\example.com
&nbsp; &nbsp;
04/13/2015 10:44 PM &lt;DIR&gt; . 04/13/2015 10:44 PM &lt;DIR&gt; .
04/13/2015 10:44 PM &lt;DIR&gt; .. 04/13/2015 10:44 PM &lt;DIR&gt; ..
04/13/2015 10:44 PM &lt;DIR&gt; archetypes 04/13/2015 10:44 PM &lt;DIR&gt; archetypes
@ -89,7 +87,7 @@ D:\Hugo\Sites\example.com&gt;dir
04/13/2015 10:44 PM &lt;DIR&gt; static 04/13/2015 10:44 PM &lt;DIR&gt; static
1 File(s) 83 bytes 1 File(s) 83 bytes
7 Dir(s) 6,273,331,200 bytes free 7 Dir(s) 6,273,331,200 bytes free
</code></pre> {{< /nohighlight >}}
You now have Hugo installed and a site to work with. You need to add a layout (or theme), then create some content. Go to http://gohugo.io/overview/quickstart/ for steps on doing that. You now have Hugo installed and a site to work with. You need to add a layout (or theme), then create some content. Go to http://gohugo.io/overview/quickstart/ for steps on doing that.

View file

@ -62,59 +62,61 @@ As an example, I was using a custom [`image_tag`](https://github.com/alexandre-n
Jekyll's plugin: Jekyll's plugin:
module Jekyll ```ruby
class ImageTag < Liquid::Tag module Jekyll
@url = nil class ImageTag < Liquid::Tag
@caption = nil @url = nil
@class = nil @caption = nil
@link = nil @class = nil
// Patterns @link = nil
IMAGE_URL_WITH_CLASS_AND_CAPTION = // Patterns
IMAGE_URL_WITH_CLASS_AND_CAPTION_AND_LINK = /(\w+)(\s+)((https?:\/\/|\/)(\S+))(\s+)"(.*?)"(\s+)->((https?:\/\/|\/)(\S+))(\s*)/i IMAGE_URL_WITH_CLASS_AND_CAPTION =
IMAGE_URL_WITH_CAPTION = /((https?:\/\/|\/)(\S+))(\s+)"(.*?)"/i IMAGE_URL_WITH_CLASS_AND_CAPTION_AND_LINK = /(\w+)(\s+)((https?:\/\/|\/)(\S+))(\s+)"(.*?)"(\s+)->((https?:\/\/|\/)(\S+))(\s*)/i
IMAGE_URL_WITH_CLASS = /(\w+)(\s+)((https?:\/\/|\/)(\S+))/i IMAGE_URL_WITH_CAPTION = /((https?:\/\/|\/)(\S+))(\s+)"(.*?)"/i
IMAGE_URL = /((https?:\/\/|\/)(\S+))/i IMAGE_URL_WITH_CLASS = /(\w+)(\s+)((https?:\/\/|\/)(\S+))/i
def initialize(tag_name, markup, tokens) IMAGE_URL = /((https?:\/\/|\/)(\S+))/i
super def initialize(tag_name, markup, tokens)
if markup =~ IMAGE_URL_WITH_CLASS_AND_CAPTION_AND_LINK super
@class = $1 if markup =~ IMAGE_URL_WITH_CLASS_AND_CAPTION_AND_LINK
@url = $3 @class = $1
@caption = $7 @url = $3
@link = $9 @caption = $7
elsif markup =~ IMAGE_URL_WITH_CLASS_AND_CAPTION @link = $9
@class = $1 elsif markup =~ IMAGE_URL_WITH_CLASS_AND_CAPTION
@url = $3 @class = $1
@caption = $7 @url = $3
elsif markup =~ IMAGE_URL_WITH_CAPTION @caption = $7
@url = $1 elsif markup =~ IMAGE_URL_WITH_CAPTION
@caption = $5 @url = $1
elsif markup =~ IMAGE_URL_WITH_CLASS @caption = $5
@class = $1 elsif markup =~ IMAGE_URL_WITH_CLASS
@url = $3 @class = $1
elsif markup =~ IMAGE_URL @url = $3
@url = $1 elsif markup =~ IMAGE_URL
end @url = $1
end
def render(context)
if @class
source = "<figure class='#{@class}'>"
else
source = "<figure>"
end
if @link
source += "<a href=\"#{@link}\">"
end
source += "<img src=\"#{@url}\">"
if @link
source += "</a>"
end
source += "<figcaption>#{@caption}</figcaption>" if @caption
source += "</figure>"
source
end
end end
end end
Liquid::Template.register_tag('image', Jekyll::ImageTag) def render(context)
if @class
source = "<figure class='#{@class}'>"
else
source = "<figure>"
end
if @link
source += "<a href=\"#{@link}\">"
end
source += "<img src=\"#{@url}\">"
if @link
source += "</a>"
end
source += "<figcaption>#{@caption}</figcaption>" if @caption
source += "</figure>"
source
end
end
end
Liquid::Template.register_tag('image', Jekyll::ImageTag)
```
is written as this Hugo shortcode: is written as this Hugo shortcode:

View file

@ -0,0 +1 @@
<pre><code class="hljs nohighlight">{{ .Inner }}</code></pre>