Great to hear that. Now we need to let the content and templates work together.
I assume, you’ve copied your files into the content
folder. How you structure the depends on you (and maybe on your current one). Each subfolder in content is a so-called section, e.g. posts
.
So far, Hugo supports Markdown natively and restructured Text / Asciidoc with third party tools as file formats. However, each content file has to have a frontmatter at the beginning. The frontmatter stores metadata about your pages/posts likethe date of creation, a title etc. I don’t know your data structure but, if necessary, you would have to add these information yourself.
Now, let’s handle the templates. Within layouts
you can create a subfolder called _default
.
A template called single.html
will specify how your content pages should look like by default. It will be used for the generation of a single blog post.
Furthermore, Hugo uses the list.html
template to generate an index page for a section. For example, this template will be shown if you enter www.example.com/post/index.html
. Here you can list all the files of that section if you like.
Setting variables works with the standard Go template syntax:
{{ $var := 42 }}
But setting a title this way isn’t that elegant. As I mentioned above, usually each content file has a title variable in it’s frontmatter. Within a template you can call it by
{{ .Page.title }}
This works also with every other variable of the frontmatter. .Page
gives you access to information that are related to the current page.
If you want to set a global title for pages we could define it in the config file. In an example config file we can set:
config.toml
title = "Jan's website"
Within the templates we can access this variable with the .Site
object which contains all informations about the website itself (mostly variables from the config file). You can access the title in the template by
{{ .Site.Title }}
Optionally, you could combine both to generate a nice title:
<title>{{ .Page.title }} - {{ .Site.Title }}</title>
If this doesn’t fit your needs tell me what the variable should represent or what should be stored.