Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/siegerts/hugo-theme-basic.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Siegert <stephen.siegert@sas.com>2019-02-16 17:32:29 +0300
committerStephen Siegert <stephen.siegert@sas.com>2019-02-16 17:32:29 +0300
commit70331acab94e6d1dd1146b108de838d2707d7960 (patch)
treec5b217056a792a08061fcbc7a60bd81236cffeaa /exampleSite
parent1e6ec9abf11fa3b229af2cdd84c0a964076d0f0a (diff)
update theme readme, exampleSite, and showcase images
Diffstat (limited to 'exampleSite')
-rw-r--r--exampleSite/config.toml8
-rwxr-xr-xexampleSite/content/blog/creating-a-new-theme.md193
-rwxr-xr-xexampleSite/content/blog/hugoisforlovers.md13
-rwxr-xr-xexampleSite/content/blog/migrate-from-jekyll.md25
-rwxr-xr-xexampleSite/content/blog/post-with-featured-image.md7
-rwxr-xr-xexampleSite/content/blog/the-figure-shortcode.md9
-rwxr-xr-xexampleSite/content/blog/typography.md37
7 files changed, 149 insertions, 143 deletions
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index 5924b89..713d09b 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -1,10 +1,10 @@
baseurl = "https://www.example.com"
-title = "Example"
+title = "Example Site"
theme ="hugo-theme-basic"
languageCode = "en-us"
googleAnalytics = ""
enableEmoji = true
-copyright = "© 2016-19 Example"
+copyright = "© 2016-19 Example Site Author"
[taxonomies]
category = "categories"
@@ -21,6 +21,10 @@ copyright = "© 2016-19 Example"
[[params.menu]]
name = "blog"
url = "blog/"
+
+[[params.menu]]
+ name = "post series"
+ url = "series/"
[[params.menu]]
diff --git a/exampleSite/content/blog/creating-a-new-theme.md b/exampleSite/content/blog/creating-a-new-theme.md
index c003815..dadebae 100755
--- a/exampleSite/content/blog/creating-a-new-theme.md
+++ b/exampleSite/content/blog/creating-a-new-theme.md
@@ -1,8 +1,9 @@
----
-author: "Michael Henderson"
-date: 2014-09-28
-title: Creating a New Theme
----
++++
+author = "Michael Henderson"
+date = 2014-09-28
+title = "Creating a New Theme"
+series = "Hugo 101"
++++
## Introduction
@@ -10,7 +11,7 @@ This tutorial will show you how to create a simple theme in Hugo. I assume that
We'll start with creating a new site with a very basic template. Then we'll add in a few pages and posts. With small variations on that, you will be able to create many different types of web sites.
-In this tutorial, commands that you enter will start with the "$" prompt. The output will follow. Lines that start with "#" are comments that I've added to explain a point. When I show updates to a file, the ":wq" on the last line means to save the file.
+In this tutorial, commands that you enter will start with the "\$" prompt. The output will follow. Lines that start with "#" are comments that I've added to explain a point. When I show updates to a file, the ":wq" on the last line means to save the file.
Here's an example:
@@ -40,7 +41,6 @@ bah and humbug
$
```
-
## Some Definitions
There are a few concepts that you need to understand before creating a theme.
@@ -49,15 +49,15 @@ There are a few concepts that you need to understand before creating a theme.
Skins are the files responsible for the look and feel of your site. It’s the CSS that controls colors and fonts, it’s the Javascript that determines actions and reactions. It’s also the rules that Hugo uses to transform your content into the HTML that the site will serve to visitors.
-You have two ways to create a skin. The simplest way is to create it in the ```layouts/``` directory. If you do, then you don’t have to worry about configuring Hugo to recognize it. The first place that Hugo will look for rules and files is in the ```layouts/``` directory so it will always find the skin.
+You have two ways to create a skin. The simplest way is to create it in the `layouts/` directory. If you do, then you don’t have to worry about configuring Hugo to recognize it. The first place that Hugo will look for rules and files is in the `layouts/` directory so it will always find the skin.
-Your second choice is to create it in a sub-directory of the ```themes/``` directory. If you do, then you must always tell Hugo where to search for the skin. It’s extra work, though, so why bother with it?
+Your second choice is to create it in a sub-directory of the `themes/` directory. If you do, then you must always tell Hugo where to search for the skin. It’s extra work, though, so why bother with it?
-The difference between creating a skin in ```layouts/``` and creating it in ```themes/``` is very subtle. A skin in ```layouts/``` can’t be customized without updating the templates and static files that it is built from. A skin created in ```themes/```, on the other hand, can be and that makes it easier for other people to use it.
+The difference between creating a skin in `layouts/` and creating it in `themes/` is very subtle. A skin in `layouts/` can’t be customized without updating the templates and static files that it is built from. A skin created in `themes/`, on the other hand, can be and that makes it easier for other people to use it.
-The rest of this tutorial will call a skin created in the ```themes/``` directory a theme.
+The rest of this tutorial will call a skin created in the `themes/` directory a theme.
-Note that you can use this tutorial to create a skin in the ```layouts/``` directory if you wish to. The main difference will be that you won’t need to update the site’s configuration file to use a theme.
+Note that you can use this tutorial to create a skin in the `layouts/` directory if you wish to. The main difference will be that you won’t need to update the site’s configuration file to use a theme.
### The Home Page
@@ -67,7 +67,7 @@ The home page, or landing page, is the first page that many visitors to a site s
When Hugo runs, it looks for a configuration file that contains settings that override default values for the entire site. The file can use TOML, YAML, or JSON. I prefer to use TOML for my configuration files. If you prefer to use JSON or YAML, you’ll need to translate my examples. You’ll also need to change the name of the file since Hugo uses the extension to determine how to process it.
-Hugo translates Markdown files into HTML. By default, Hugo expects to find Markdown files in your ```content/``` directory and template files in your ```themes/``` directory. It will create HTML files in your ```public/``` directory. You can change this by specifying alternate locations in the configuration file.
+Hugo translates Markdown files into HTML. By default, Hugo expects to find Markdown files in your `content/` directory and template files in your `themes/` directory. It will create HTML files in your `public/` directory. You can change this by specifying alternate locations in the configuration file.
### Content
@@ -142,13 +142,13 @@ INFO: 2014/09/29 Using config file: config.toml
INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/
WARN: 2014/09/29 Unable to locate layout: [index.html _default/list.html _default/single.html]
WARN: 2014/09/29 Unable to locate layout: [404.html]
-0 draft content
-0 future content
-0 pages created
+0 draft content
+0 future content
+0 pages created
0 tags created
0 categories created
in 2 ms
-$
+$
```
The "`--verbose`" flag gives extra information that will be helpful when we build the template. Every line of the output that starts with "INFO:" or "WARN:" is present because we used that flag. The lines that start with "WARN:" are warning messages. We'll go over them later.
@@ -174,13 +174,11 @@ $ ls -l public
total 16
-rw-r--r-- 1 quoha staff 416 Sep 29 17:02 index.xml
-rw-r--r-- 1 quoha staff 262 Sep 29 17:02 sitemap.xml
-$
+$
```
Hugo created two XML files, which is standard, but there are no HTML files.
-
-
### Test the New Site
Verify that you can run the built-in web server. It will dramatically shorten your development cycle if you do. Start it by running the "server" command. If it is successful, you will see output similar to the following:
@@ -191,9 +189,9 @@ INFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.toml
INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/
WARN: 2014/09/29 Unable to locate layout: [index.html _default/list.html _default/single.html]
WARN: 2014/09/29 Unable to locate layout: [404.html]
-0 draft content
-0 future content
-0 pages created
+0 draft content
+0 future content
+0 pages created
0 tags created
0 categories created
in 2 ms
@@ -222,7 +220,7 @@ That second warning is easier to explain. We haven’t created a template to be
Now for the first warning. It is for the home page. You can tell because the first layout that it looked for was “index.html.” That’s only used by the home page.
-I like that the verbose flag causes Hugo to list the files that it's searching for. For the home page, they are index.html, _default/list.html, and _default/single.html. There are some rules that we'll cover later that explain the names and paths. For now, just remember that Hugo couldn't find a template for the home page and it told you so.
+I like that the verbose flag causes Hugo to list the files that it's searching for. For the home page, they are index.html, \_default/list.html, and \_default/single.html. There are some rules that we'll cover later that explain the names and paths. For now, just remember that Hugo couldn't find a template for the home page and it told you so.
At this point, you've got a working installation and site that we can build upon. All that’s left is to add some content and a theme to display it.
@@ -234,7 +232,6 @@ We're going to create a new theme called "zafta." Since the goal of this tutoria
All themes have opinions on content and layout. For example, Zafta uses "post" over "blog". Strong opinions make for simpler templates but differing opinions make it tougher to use themes. When you build a theme, consider using the terms that other themes do.
-
### Create a Skeleton
Use the hugo "new" command to create the skeleton of a theme. This creates the directory structure and places empty files for you to fill out.
@@ -261,7 +258,7 @@ $ find themes -type f | xargs ls -l
-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/partials/footer.html
-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/partials/header.html
-rw-r--r-- 1 quoha staff 93 Sep 29 17:31 themes/zafta/theme.toml
-$
+$
```
The skeleton includes templates (the files ending in .html), license file, a description of your theme (the theme.toml file), and an empty archetype.
@@ -294,8 +291,6 @@ $ find themes/zafta -name '*.html' | xargs ls -l
$
```
-
-
### Update the Configuration File to Use the Theme
Now that we've got a theme to work with, it's a good idea to add the theme name to the configuration file. This is optional, because you can always add "-t zafta" on all your commands. I like to put it the configuration file because I like shorter command lines. If you don't put it in the configuration file or specify it on the command line, you won't use the template that you're expecting to.
@@ -324,9 +319,9 @@ INFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.toml
INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /Users/quoha/Sites/zafta/public/
INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/
WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html]
-0 draft content
-0 future content
-0 pages created
+0 draft content
+0 future content
+0 pages created
0 tags created
0 categories created
in 2 ms
@@ -371,7 +366,7 @@ When Hugo created our theme, it created an empty home page template. Now, when w
$ find . -name index.html | xargs ls -l
-rw-r--r-- 1 quoha staff 0 Sep 29 20:21 ./public/index.html
-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 ./themes/zafta/layouts/index.html
-$
+$
```
#### The Magic of Static
@@ -390,7 +385,7 @@ drwxr-xr-x 4 quoha staff 136 Sep 29 17:31 themes/zafta/layouts/partials
drwxr-xr-x 4 quoha staff 136 Sep 29 17:31 themes/zafta/static
drwxr-xr-x 2 quoha staff 68 Sep 29 17:31 themes/zafta/static/css
drwxr-xr-x 2 quoha staff 68 Sep 29 17:31 themes/zafta/static/js
-$
+$
```
## The Theme Development Cycle
@@ -410,7 +405,7 @@ Check the main Hugo site for information on using Git with Hugo.
### Purge the public/ Directory
-When generating the site, Hugo will create new files and update existing ones in the ```public/``` directory. It will not delete files that are no longer used. For example, files that were created in the wrong directory or with the wrong title will remain. If you leave them, you might get confused by them later. I recommend cleaning out your site prior to generating it.
+When generating the site, Hugo will create new files and update existing ones in the `public/` directory. It will not delete files that are no longer used. For example, files that were created in the wrong directory or with the wrong title will remain. If you leave them, you might get confused by them later. I recommend cleaning out your site prior to generating it.
Note: If you're building on an SSD, you should ignore this. Churning on a SSD can be costly.
@@ -438,7 +433,6 @@ $ hugo server --watch --verbose
Here's sample output showing Hugo detecting a change to the template for the home page. Once generated, the web browser automatically reloaded the page. I've said this before, it's amazing.
-
```
$ rm -rf public
$ hugo server --watch --verbose
@@ -446,9 +440,9 @@ INFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.toml
INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /Users/quoha/Sites/zafta/public/
INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/
WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html]
-0 draft content
-0 future content
-0 pages created
+0 draft content
+0 future content
+0 pages created
0 tags created
0 categories created
in 2 ms
@@ -460,9 +454,9 @@ INFO: 2014/09/29 File System Event: ["/Users/quoha/Sites/zafta/themes/zafta/layo
Change detected, rebuilding site
WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html]
-0 draft content
-0 future content
-0 pages created
+0 draft content
+0 future content
+0 pages created
0 tags created
0 categories created
in 1 ms
@@ -473,8 +467,8 @@ in 1 ms
The home page is one of a few special pages that Hugo creates automatically. As mentioned earlier, it looks for one of three files in the theme's layout/ directory:
1. index.html
-2. _default/list.html
-3. _default/single.html
+2. \_default/list.html
+3. \_default/single.html
We could update one of the default templates, but a good design decision is to update the most specific template available. That's not a hard and fast rule (in fact, we'll break it a few times in this tutorial), but it is a good generalization.
@@ -484,12 +478,12 @@ Right now, that page is empty because we don't have any content and we don't hav
```
$ vi themes/zafta/layouts/index.html
-<!DOCTYPE html>
-<html>
-<body>
- <p>hugo says hello!</p>
-</body>
-</html>
+<!DOCTYPE html>
+<html>
+<body>
+ <p>hugo says hello!</p>
+</body>
+</html>
:wq
$
@@ -503,9 +497,9 @@ INFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.toml
INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /Users/quoha/Sites/zafta/public/
INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/
WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html]
-0 draft content
-0 future content
-0 pages created
+0 draft content
+0 future content
+0 pages created
0 tags created
0 categories created
in 2 ms
@@ -513,11 +507,11 @@ in 2 ms
$ find public -type f -name '*.html' | xargs ls -l
-rw-r--r-- 1 quoha staff 78 Sep 29 21:26 public/index.html
-$ cat public/index.html
-<!DOCTYPE html>
-<html>
-<body>
- <p>hugo says hello!</p>
+$ cat public/index.html
+<!DOCTYPE html>
+<html>
+<body>
+ <p>hugo says hello!</p>
</html>
```
@@ -526,15 +520,15 @@ $ cat public/index.html
Note: If you're running the server with the `--watch` option, you'll see different content in the file:
```
-$ cat public/index.html
-<!DOCTYPE html>
-<html>
-<body>
- <p>hugo says hello!</p>
-<script>document.write('<script src="http://'
- + (location.host || 'localhost').split(':')[0]
- + ':1313/livereload.js?mindelay=10"></'
- + 'script>')</script></body>
+$ cat public/index.html
+<!DOCTYPE html>
+<html>
+<body>
+ <p>hugo says hello!</p>
+<script>document.write('<script src="http://'
+ + (location.host || 'localhost').split(':')[0]
+ + ':1313/livereload.js?mindelay=10"></'
+ + 'script>')</script></body>
</html>
```
@@ -557,7 +551,7 @@ INFO: 2014/09/29 attempting to create post/first.md of post
INFO: 2014/09/29 curpath: /Users/quoha/Sites/zafta/themes/zafta/archetypes/default.md
ERROR: 2014/09/29 Unable to Cast <nil> to map[string]interface{}
-$
+$
```
That wasn't very nice, was it?
@@ -596,7 +590,7 @@ total 16
-rw-r--r-- 1 quoha staff 104 Sep 29 21:54 first.md
-rw-r--r-- 1 quoha staff 105 Sep 29 21:57 second.md
-$ cat content/post/first.md
+$ cat content/post/first.md
+++
Categories = []
Description = ""
@@ -607,7 +601,7 @@ title = "first"
+++
my first post
-$ cat content/post/second.md
+$ cat content/post/second.md
+++
Categories = []
Description = ""
@@ -618,7 +612,7 @@ title = "second"
+++
my second post
-$
+$
```
Build the web site and then verify the results.
@@ -631,9 +625,9 @@ INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /
INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/
INFO: 2014/09/29 found taxonomies: map[string]string{"category":"categories", "tag":"tags"}
WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html]
-0 draft content
-0 future content
-2 pages created
+0 draft content
+0 future content
+2 pages created
0 tags created
0 categories created
in 4 ms
@@ -666,7 +660,7 @@ There are three other types of templates: partials, content views, and terms. We
The home page will contain a list of posts. Let's update its template to add the posts that we just created. The logic in the template will run every time we build the site.
```
-$ vi themes/zafta/layouts/index.html
+$ vi themes/zafta/layouts/index.html
<!DOCTYPE html>
<html>
<body>
@@ -704,26 +698,26 @@ INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /
INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/
INFO: 2014/09/29 found taxonomies: map[string]string{"tag":"tags", "category":"categories"}
WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html]
-0 draft content
-0 future content
-2 pages created
+0 draft content
+0 future content
+2 pages created
0 tags created
0 categories created
in 4 ms
-$ find public -type f -name '*.html' | xargs ls -l
+$ find public -type f -name '*.html' | xargs ls -l
-rw-r--r-- 1 quoha staff 94 Sep 29 22:23 public/index.html
-rw-r--r-- 1 quoha staff 0 Sep 29 22:23 public/post/first/index.html
-rw-r--r-- 1 quoha staff 0 Sep 29 22:23 public/post/index.html
-rw-r--r-- 1 quoha staff 0 Sep 29 22:23 public/post/second/index.html
-$ cat public/index.html
+$ cat public/index.html
<!DOCTYPE html>
<html>
<body>
-
+
<h1>second</h1>
-
+
<h1>first</h1>
-
+
</body>
</html>
$
@@ -737,7 +731,7 @@ And, if that were entirely true, this tutorial would be much shorter. There are
We're working with posts, which are in the content/post/ directory. That means that their section is "post" (and if we don't do something weird, their type is also "post").
-Hugo uses the section and type to find the template file for every piece of content. Hugo will first look for a template file that matches the section or type name. If it can't find one, then it will look in the _default/ directory. There are some twists that we'll cover when we get to categories and tags, but for now we can assume that Hugo will try post/single.html, then _default/single.html.
+Hugo uses the section and type to find the template file for every piece of content. Hugo will first look for a template file that matches the section or type name. If it can't find one, then it will look in the \_default/ directory. There are some twists that we'll cover when we get to categories and tags, but for now we can assume that Hugo will try post/single.html, then \_default/single.html.
Now that we know the search rule, let's see what we actually have available:
@@ -755,7 +749,7 @@ Please see the Hugo documentation on template rendering for all the details on d
#### Update the Template File
```
-$ vi themes/zafta/layouts/_default/single.html
+$ vi themes/zafta/layouts/_default/single.html
<!DOCTYPE html>
<html>
<head>
@@ -781,9 +775,9 @@ INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /
INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/
INFO: 2014/09/29 found taxonomies: map[string]string{"tag":"tags", "category":"categories"}
WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html]
-0 draft content
-0 future content
-2 pages created
+0 draft content
+0 future content
+2 pages created
0 tags created
0 categories created
in 4 ms
@@ -794,7 +788,7 @@ $ find public -type f -name '*.html' | xargs ls -l
-rw-r--r-- 1 quoha staff 0 Sep 29 22:40 public/post/index.html
-rw-r--r-- 1 quoha staff 128 Sep 29 22:40 public/post/second/index.html
-$ cat public/post/first/index.html
+$ cat public/post/first/index.html
<!DOCTYPE html>
<html>
<head>
@@ -807,7 +801,7 @@ $ cat public/post/first/index.html
</body>
</html>
-$ cat public/post/second/index.html
+$ cat public/post/second/index.html
<!DOCTYPE html>
<html>
<head>
@@ -850,9 +844,9 @@ INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /
INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/
INFO: 2014/09/29 found taxonomies: map[string]string{"tag":"tags", "category":"categories"}
WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html]
-0 draft content
-0 future content
-2 pages created
+0 draft content
+0 future content
+2 pages created
0 tags created
0 categories created
in 4 ms
@@ -863,15 +857,15 @@ $ find public -type f -name '*.html' | xargs ls -l
-rw-r--r-- 1 quoha staff 0 Sep 29 22:44 public/post/index.html
-rw-r--r-- 1 quoha staff 128 Sep 29 22:44 public/post/second/index.html
-$ cat public/index.html
+$ cat public/index.html
<!DOCTYPE html>
<html>
<body>
-
+
<h1><a href="/post/second/">second</a></h1>
-
+
<h1><a href="/post/first/">first</a></h1>
-
+
</body>
</html>
@@ -889,7 +883,7 @@ $ find themes/zafta -name list.html | xargs ls -l
-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/_default/list.html
```
-As with the single post, we have to decide to update _default/list.html or create post/list.html. We still don't have multiple content types, so let's stay consistent and update the default list template.
+As with the single post, we have to decide to update \_default/list.html or create post/list.html. We still don't have multiple content types, so let's stay consistent and update the default list template.
## Creating Top Level Pages
@@ -898,7 +892,7 @@ Let's add an "about" page and display it at the top level (as opposed to a sub-l
The default in Hugo is to use the directory structure of the content/ directory to guide the location of the generated html in the public/ directory. Let's verify that by creating an "about" page at the top level:
```
-$ vi content/about.md
+$ vi content/about.md
+++
title = "about"
description = "about this site"
@@ -1025,10 +1019,13 @@ The most noticeable difference between a template call and a partials call is th
```
{{ template "theme/partials/header.html" . }}
```
+
versus
+
```
{{ partial "header.html" . }}
```
+
Both pass in the context.
Let's change the home page template to use these new partials.
diff --git a/exampleSite/content/blog/hugoisforlovers.md b/exampleSite/content/blog/hugoisforlovers.md
index 747ab41..b141af7 100755
--- a/exampleSite/content/blog/hugoisforlovers.md
+++ b/exampleSite/content/blog/hugoisforlovers.md
@@ -7,7 +7,7 @@ tags = [
"development",
]
date = "2014-04-02"
-toc = true
+series = "Hugo 101"
+++
## Step 1. Install Hugo
@@ -26,10 +26,10 @@ you are reading right now.
Follow the following steps:
- 1. Clone the [Hugo repository](http://github.com/spf13/hugo)
- 2. Go into the repo
- 3. Run hugo in server mode and build the docs
- 4. Open your browser to http://localhost:1313
+1. Clone the [Hugo repository](http://github.com/spf13/hugo)
+2. Go into the repo
+3. Run hugo in server mode and build the docs
+4. Open your browser to http://localhost:1313
Corresponding pseudo commands:
@@ -58,9 +58,8 @@ Now we are going to run hugo again, but this time with hugo in watch mode.
> Watching for changes in /Users/spf13/Code/hugo/docs/content
> Press ctrl+c to stop
-
Open your [favorite editor](http://vim.spf13.com) and change one of the source
-content pages. How about changing this very file to *fix the typo*. How about changing this very file to *fix the typo*.
+content pages. How about changing this very file to _fix the typo_. How about changing this very file to _fix the typo_.
Content files are found in `docs/content/`. Unless otherwise specified, files
are located at the same relative location as the url, in our case
diff --git a/exampleSite/content/blog/migrate-from-jekyll.md b/exampleSite/content/blog/migrate-from-jekyll.md
index d5b2f54..8dd03d5 100755
--- a/exampleSite/content/blog/migrate-from-jekyll.md
+++ b/exampleSite/content/blog/migrate-from-jekyll.md
@@ -1,10 +1,11 @@
----
-date: 2014-03-10
-title: Migrate to Hugo from Jekyll
-toc: true
----
++++
+date = 2014-03-10
+title = "Migrate to Hugo from Jekyll"
+series = "Hugo 101"
++++
## Move static content to `static`
+
Jekyll has a rule that any directory not starting with `_` will be copied as-is to the `_site` output. Hugo keeps all static content under `static`. You should therefore move it all there.
With Jekyll, something that looked like
@@ -22,18 +23,20 @@ should become
Additionally, you'll want any files that should reside at the root (such as `CNAME`) to be moved to `static`.
## Create your Hugo configuration file
+
Hugo can read your configuration as JSON, YAML or TOML. Hugo supports parameters custom configuration too. Refer to the [Hugo configuration documentation](/overview/configuration/) for details.
## Set your configuration publish folder to `_site`
+
The default is for Jekyll to publish to `_site` and for Hugo to publish to `public`. If, like me, you have [`_site` mapped to a git submodule on the `gh-pages` branch](http://blog.blindgaenger.net/generate_github_pages_in_a_submodule.html), you'll want to do one of two alternatives:
-1. Change your submodule to point to map `gh-pages` to public instead of `_site` (recommended).
+1. Change your submodule to point to map `gh-pages` to public instead of `_site` (recommended).
git submodule deinit _site
git rm _site
git submodule add -b gh-pages git@github.com:your-username/your-repo.git public
-2. Or, change the Hugo configuration to use `_site` instead of `public`.
+2. Or, change the Hugo configuration to use `_site` instead of `public`.
{
..
@@ -42,14 +45,17 @@ The default is for Jekyll to publish to `_site` and for Hugo to publish to `publ
}
## Convert Jekyll templates to Hugo templates
+
That's the bulk of the work right here. The documentation is your friend. You should refer to [Jekyll's template documentation](http://jekyllrb.com/docs/templates/) if you need to refresh your memory on how you built your blog and [Hugo's template](/layout/templates/) to learn Hugo's way.
As a single reference data point, converting my templates for [heyitsalex.net](http://heyitsalex.net/) took me no more than a few hours.
## Convert Jekyll plugins to Hugo shortcodes
+
Jekyll has [plugins](http://jekyllrb.com/docs/plugins/); Hugo has [shortcodes](/doc/shortcodes/). It's fairly trivial to do a port.
### Implementation
+
As an example, I was using a custom [`image_tag`](https://github.com/alexandre-normand/alexandre-normand/blob/74bb12036a71334fdb7dba84e073382fc06908ec/_plugins/image_tag.rb) plugin to generate figures with caption when running Jekyll. As I read about shortcodes, I found Hugo had a nice built-in shortcode that does exactly the same thing.
Jekyll's plugin:
@@ -130,6 +136,7 @@ is written as this Hugo shortcode:
<!-- image -->
### Usage
+
I simply changed:
{% image full http://farm5.staticflickr.com/4136/4829260124_57712e570a_o_d.jpg "One of my favorite touristy-type photos. I secretly waited for the good light while we were "having fun" and took this. Only regret: a stupid pole in the top-left corner of the frame I had to clumsily get rid of at post-processing." ->http://www.flickr.com/photos/alexnormand/4829260124/in/set-72157624547713078/ %}
@@ -141,11 +148,15 @@ to this (this example uses a slightly extended version named `fig`, different th
As a bonus, the shortcode named parameters are, arguably, more readable.
## Finishing touches
+
### Fix content
+
Depending on the amount of customization that was done with each post with Jekyll, this step will require more or less effort. There are no hard and fast rules here except that `hugo server --watch` is your friend. Test your changes and fix errors as needed.
### Clean up
+
You'll want to remove the Jekyll configuration at this point. If you have anything else that isn't used, delete it.
## A practical example in a diff
+
[Hey, it's Alex](http://heyitsalex.net/) was migrated in less than a _father-with-kids day_ from Jekyll to Hugo. You can see all the changes (and screw-ups) by looking at this [diff](https://github.com/alexandre-normand/alexandre-normand/compare/869d69435bd2665c3fbf5b5c78d4c22759d7613a...b7f6605b1265e83b4b81495423294208cc74d610).
diff --git a/exampleSite/content/blog/post-with-featured-image.md b/exampleSite/content/blog/post-with-featured-image.md
index c42ff5c..43fd10c 100755
--- a/exampleSite/content/blog/post-with-featured-image.md
+++ b/exampleSite/content/blog/post-with-featured-image.md
@@ -2,14 +2,12 @@
title: "Post With Featured Image"
date: 2018-10-01T16:15:09+08:00
draft: false
-images:
- - https://picsum.photos/1024/768/?random
-tags:
+tags:
- Demo
- Image
---
-Just define the image URL in the content’s front matter, the featured image will be displayed as the background.
+Just define the image URL in the content’s front matter, the featured image will be displayed as the background.
For example:
@@ -18,6 +16,7 @@ For example:
images:
- https://picsum.photos/1024/768/?random
---
+
```
This is an array, you can set multiple urls, only the first url will be used. These images is also used in [Twitter Cards](https://developer.twitter.com/en/docs/tweets/optimize-with-cards/guides/getting-started.html) and the [Open Graph](http://ogp.me/) metadata.
diff --git a/exampleSite/content/blog/the-figure-shortcode.md b/exampleSite/content/blog/the-figure-shortcode.md
index bfbe7e8..e3e106f 100755
--- a/exampleSite/content/blog/the-figure-shortcode.md
+++ b/exampleSite/content/blog/the-figure-shortcode.md
@@ -2,8 +2,7 @@
title: 'The "figure" Shortcode'
date: 2018-12-24T12:29:41+08:00
draft: false
-featuredImg: ""
-tags:
+tags:
- demo
- image
---
@@ -14,9 +13,9 @@ https://gohugo.io/content-management/shortcodes/#figure
This theme has 3 CSS classes made for figure elements:
-* `big`: images will break the width limit of main content area.
-* `left`: images will float to the left.
-* `right`: images will float to the right.
+- `big`: images will break the width limit of main content area.
+- `left`: images will float to the left.
+- `right`: images will float to the right.
If a figure has no class set, the image will behave just like a normal markdown image: `![]()`.
diff --git a/exampleSite/content/blog/typography.md b/exampleSite/content/blog/typography.md
index 94f469b..29ffeba 100755
--- a/exampleSite/content/blog/typography.md
+++ b/exampleSite/content/blog/typography.md
@@ -2,8 +2,7 @@
title: "Typography"
date: 2018-09-29T11:36:33+08:00
draft: false
-featuredImg: ""
-tags:
+tags:
- Demo
- Typography
---
@@ -16,9 +15,7 @@ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor i
Inline styles:
-**strong**, *emphasis*, ***strong and emphasis***,`code`, <u>underline</u>, ~~strikethrough~~, :joy:🤣, $\LaTeX$, X^2^, H~2~O, ==highlight==, [Link](https://example.com), and image:
-
-![img](https://picsum.photos/600/400/?random)
+**strong**, _emphasis_, **_strong and emphasis_**,`code`, <u>underline</u>, ~~strikethrough~~, :joy:🤣, $\LaTeX$, X^2^, H~2~O, ==highlight==, [Link](https://example.com), and image:
---
@@ -40,30 +37,30 @@ Table:
| Left-Aligned | Center Aligned | Right Aligned |
| :------------ | :-------------: | ------------: |
-| col 3 is | some wordy text | $1600 |
-| col 2 is | centered | $12 |
-| zebra stripes | are neat | $1 |
+| col 3 is | some wordy text | \$1600 |
+| col 2 is | centered | \$12 |
+| zebra stripes | are neat | \$1 |
Lists:
-* Unordered list item 1.
-* Unordered list item 2.
+- Unordered list item 1.
+- Unordered list item 2.
1. ordered list item 1.
2. ordered list item 2.
- + sub-unordered list item 1.
- + sub-unordered list item 2.
- + [x] something is DONE.
- + [ ] something is NOT DONE.
+ - sub-unordered list item 1.
+ - sub-unordered list item 2.
+ - [x] something is DONE.
+ - [ ] something is NOT DONE.
Syntax Highlighting:
```javascript
-var num1, num2, sum
-num1 = prompt("Enter first number")
-num2 = prompt("Enter second number")
-sum = parseInt(num1) + parseInt(num2) // "+" means "add"
-alert("Sum = " + sum) // "+" means combine into a string
+var num1, num2, sum;
+num1 = prompt("Enter first number");
+num2 = prompt("Enter second number");
+sum = parseInt(num1) + parseInt(num2); // "+" means "add"
+alert("Sum = " + sum); // "+" means combine into a string
```
-[^1]: From https://en.wikipedia.org/wiki/Apple \ No newline at end of file
+[^1]: From https://en.wikipedia.org/wiki/Apple