27
0
Fork 1
forked from mirror/Mainroad

update examplesite to mainroad-v2

This commit is contained in:
Mansoor Barri 2025-01-04 06:24:07 +00:00
parent 14263bf335
commit 159b73795e
No known key found for this signature in database
GPG key ID: 4C3D91184C030FB3
12 changed files with 1310 additions and 3 deletions

6
.gitmodules vendored
View file

@ -1,3 +1,3 @@
[submodule "exampleSite/themes"]
path = exampleSite/themes
url = https://github.com/mansoorbarri/mainroad-v2
[submodule "examplesite/themes/mainroad"]
path = examplesite/themes/mainroad
url = https://github.com/mansoorbarri/mainroad-v2.git

View file

@ -0,0 +1,5 @@
+++
date = '{{ .Date }}'
draft = true
title = '{{ replace .File.ContentBaseName "-" " " | title }}'
+++

35
examplesite/config.toml Normal file
View file

@ -0,0 +1,35 @@
baseurl = "/"
title = "Mainroad"
languageCode = "en-us"
paginate = "10" # Number of posts per page
theme = "mainroad-v2" # Enable comments by entering your Disqus shortname
googleAnalytics = "" # Enable Google Analytics by entering your tracking id
[Author]
name = "John Doe"
bio = "John Doe's true identity is unknown. Maybe he is a successful blogger or writer. Nobody knows it."
avatar = "img/avatar.png"
[Params]
description = "John Doe's Personal blog about everything" # Description of your site
opengraph = true
twitter_cards = false
readmore = false # Show "Read more" button in list if true
authorbox = true
pager = true
post_meta = ["date", "categories"] # Order of post meta information
mainSections = ["post", "docs"]
[Params.logo]
subtitle = "Just another site" # Logo subtitle
[Params.sidebar]
home = "right" # Configure layout for home page
list = "right" # Configure layout for list pages
single = "right" # Configure layout for single pages
# Enable widgets in given order
widgets = ["search", "recent", "categories", "taglist"]
[Params.widgets]
recent_num = 5 # Set the number of articles in the "Recent articles" widget
tags_counter = false # Enable counter for each tag in "Tags" widget (disabled by default)

View file

@ -0,0 +1,41 @@
---
title: About
date: 2022-01-25T14:00:00.000Z
authorbox: false
sidebar: false
menu: main
---
Our website builds with [Hugo](https://gohugo.io/) static site generator and
[Mainroad](https://github.com/vimux/mainroad) theme. This demo allows you to see what Mainroad based website looks like
before deciding to go with it. Just keep in mind that the current demo shows the basics, a small part of what the
combination of Hugo and Mainroad can do.
## About Mainroad
Mainroad is a responsive, simple, clean and content-focused Hugo theme based on the MH Magazine lite WordPress theme.
Main features:
* Responsive design
* Main & secondary menus
* Widgetized sidebar
* Translations. Over 15 languages and counting
* Configurable theme settings (sidebar position, author box, post navigation, highlight color) via config.toml
* Hugo internal templates (Open Graph, Schema, Twitter Cards, Disqus, Google Analytics)
* Wide cross-browser compatibility
* Desktop: IE11+, Chrome, Firefox, Safari
* Mobile: Android browser (on Android 4.4+), Safari (on iOS 7+), Google Chrome, Opera mini
* Custom Google Fonts support, MathJax, Table of Contents, SVG icons and much more…
Learn more on [GitHub](https://github.com/vimux/mainroad). Mainroad theme is released under the
[GPLv2 license](https://github.com/vimux/mainroad/blob/master/LICENSE.md).
## About Hugo
Hugo is a static HTML and CSS website generator written in Go. It is optimized for speed, ease of use, and
configurability. Hugo takes a directory with content and templates and renders them into a full HTML website. With its
amazing speed and flexibility, Hugo makes building websites fun again.
Learn more on [GitHub](https://github.com/gohugoio/hugo). Complete documentation is available at
[Hugo Documentation](https://gohugo.io/getting-started/).

View file

@ -0,0 +1,4 @@
---
title: Documentation
description: Mainroad theme documentation, including getting started, customization guides, and FAQ.
---

View file

@ -0,0 +1,405 @@
---
title: Customization
description: Describes common Mainroad theme configuration parameters that can be adjusted via config file or via Front
Matter section.
lead: Describes common Mainroad theme configuration parameters that can be adjusted via config file or via Front Matter
section.
date: 2022-01-24T14:00:00.000Z
thumbnail:
src: "img/placeholder.png"
visibility:
- list
authorbox: false
sidebar: false
pager: false
weight: 2
menu: main
---
Customization page describes common Mainroad configuration parameters which can be specified via configuration file or
via Front Matter section. That includes logo section tuning, adding a sidebar with widgets, adjusting highlight color,
and more.
<!--more-->
This section will mainly cover customization settings that are unique to this theme. If something is not covered here,
there's a good chance it is covered somewhere in [Hugo docs](https://gohugo.io/documentation/).
### Logo
**Mainroad** allows you to set a custom logo in the site header. You may use text, or image, or both. Use the following
options in your site config:
```toml
[Params.logo]
image = "img/placeholder.png"
title = "Mainroad"
subtitle = "Just another site"
```
**Note:** logo image will display at a maximum width of 128 pixels and a maximum height of 128 pixels
when you use text and image simultaneously. When the only logo image is active, it will display at a maximum height of
256 pixels. Ideally, your logo image should be SVG.
---
If you don't set any of these variables, the theme uses the site title as a logo title. Don't need a logo section?
Disable it this way:
```toml
[Params.logo]
image = false
title = false
subtitle = false
```
### Highlight color
Mainroad uses `#e22d30` as a default highlight color, but you may choose and set any other color.
```toml
[Params.style.vars]
highlightColor = "#e22d30"
```
### Post meta
Post meta is a feature that refers to including additional meta information (such as author name, categories, date,
translations, etc.) on pages. It can be enabled via config using the `post_meta` key with a list of meta field names as
value. Order matters here: rearrange fields if you want to.
```toml
[Params]
post_meta = ["author", "date", "categories", "translations"]
```
Full list of available default post meta fields:
* `author`, `categories`, `date`, `translations`
In addition to the default meta fields, you can add your own by placing a custom partial under
`layouts/partials/post_meta/<name>.html`.
#### Post meta: `date` localization
With [Hugo v0.87.0](https://gohugo.io/news/0.87.0-relnotes/) (or later), `date` meta field shows localized dates (with
weekdays and months in the current language) by default. In most cases, such a transition is painless, but owners of
multilingual sites should be careful and check that everything translates as expected after the upgrade.
You can also use a predefined layout, like `:date_full`, and it will output localized dates or times. For additional
information about localized dates and possible date/time formatting layouts, please see
[Hugo: time.Format](https://gohugo.io/functions/dateformat/).
### Thumbnail visibility
By default, a thumbnail image has shown for a list and single pages simultaneously. In some cases, you may want to show
a thumbnail for list-like pages only and hide it on single pages (or vice versa). Control global thumbnail visibility
via config, use the key `visibility` with combination of valid values `"list"` and `"post"`.
```toml
[Params.thumbnail]
# Show thumbnail only for list items
visibility = ["list"]
```
Besides global configuration, you can change thumbnail visibility individually with extended thumbnail notation via
front matter block.
```yaml
thumbnail:
src: "img/placeholder.png"
visibility:
- list
- post
```
This page is an example of list-only thumbnail visibility.
### Sidebar
**Mainroad** comes with a configurable sidebar that can be on the left, on the right, or disabled. The default layout
can be specified in the `[Params.sidebar]` section of the configuration. The position can be specified for home, list
and single pages individually. Use the keys `home`, `list` and `single` with values `"left"`, `"right"` or `false`.
```toml
[Params.sidebar]
home = "right"
list = "right"
single = "right"
```
The layout can be configured per page, by setting the `sidebar` parameter with one of the same values (`"left"`,
`"right"` or `false`) in the page's front matter.
```yaml
sidebar: "left" # Enable sidebar (on the left side) per page
```
The sidebar consists of multiple widgets. Widgets can be enabled individually using the `widgets` key with a list of
widget names as value. You can add your own widgets, by placing a template under `layouts/partials/widgets/<name>.html`.
```toml
[Params.sidebar]
# Enable widgets in given order
widgets = ["search", "recent", "categories", "taglist", "social", "languages"]
```
The list of widgets can be overwritten from a page's front matter.
```yaml
# Enable sidebar widgets in given order
widgets:
- "search"
- "recent"
- "taglist"
```
Full list of available default widgets:
* `search`, `ddg-search`, `recent`, `categories`, `taglist`, `social`, `languages`
**Note**: DuckDuckGo widget (`ddg-search`) deprecated in favor of `search` widget.
---
Some of our widgets respect optional configuration. Have a look at the `[Params.widgets]` and `[Params.widgets.social]`
sections in the example below.
```toml
[Params.widgets]
recent_num = 5 # Set the number of articles in the "Recent articles" widget
categories_counter = false # Enable counter for each category in "Categories" widget
tags_counter = false # Enable counter for each tag in "Tags" widget
```
```toml
[Params.widgets.social]
# Enable parts of social widget
facebook = "username"
twitter = "username"
instagram = "username"
linkedin = "username"
telegram = "username"
github = "username"
gitlab = "username"
bitbucket = "username"
email = "example@example.com"
```
### Widget caching
Sidebar strongly affects overall build time, especially if you are using all of our widgets or even more. Widget caching
can significantly improve the generation time. Cached partials remain the same for all affected pages and are not
generated multiple times by Hugo. All built-in widgets (`search`, `recent`, `categories`, `taglist`, `social`,
`languages`) support caching.
Add `cached = true` inside the corresponding widget's dictionary table to activate caching. For example, to cache the
`recent` widget:
```toml
[Params.widgets.recent]
cached = true
```
The following sample configuration extract shows how to cache all standard widgets and generate your website faster:
```toml
[Params.widgets.search]
cached = true
[Params.widgets.recent]
cached = true
[Params.widgets.categories]
cached = true
[Params.widgets.taglist]
cached = true
[Params.widgets.social]
cached = true
[Params.widgets.languages]
cached = true
```
Not all widgets are cacheable. If a widget contains (can contain) different data for different pages (e.g., for TOC
generation), then it should not be cached. Always check that your modified/customized widget is cached correctly.
### Social Widget: custom links
**Mainroad** contains built-in social links in the social widget. In addition to default social links, you may set
custom links by adding `Params.widgets.social.custom` to your `config.toml`. Here is an example:
```toml
[[Params.widgets.social.custom]]
title = "My Home Page"
url = "https://example.com"
```
If you want to display an icon of your social link, you need to put SVG icon file in `layouts/partials` directory under
your site's root. The `icon` key filed, which is optional, should be a path relative to `layouts/partials`.
```toml
[[Params.widgets.social.custom]]
title = "Youtube"
url = "https://youtube.com/user/username"
icon = "youtube.svg"
```
**Note:** *Only* SVG files are supported to be used as custom social icons. If you use any other files, PNG for example,
a compile error will be raised by Hugo. Moreover, not every SVG icon can be used. For better results, it should be
one-color SVG file with a special class attribute `{{ with .class }}{{ . }} {{ end }}` and 24x24 size. At a minimum,
custom SVG icon needs these attributes:
```html
<svg class="{{ with .class }}{{ . }} {{ end }} icon" width="24" height="24">...</svg>
```
You can also specify the `rel` attribute for the link. By default, the attribute value is `"noopener noreferrer"`. You can remove the attribute completely by setting its value to `false`.
```toml
[[Params.widgets.social.custom]]
title = "My Home Page"
url = "https://example.com"
rel = "me"
[[Params.widgets.social.custom]]
title = "Youtube"
url = "https://youtube.com/user/username"
rel = false
```
### Search box widget
The search box widget can refer to the results of Google, Bing, and DuckDuckGo searches. By default, Mainroad uses
Google search if no additional configuration options are specified.
To use a different search engine, first of all, check that the search widget is enabled. Then set the search parameters
(`Site.Params.widgets.search` section) according to the data below.
**Google (default)**:
```toml
[Params.widgets.search]
url = "https://google.com/search"
[Params.widgets.search.input]
name = "sitesearch"
pre = ""
```
**DuckDuckGo**:
```toml
[Params.widgets.search]
url = "https://duckduckgo.com/"
[Params.widgets.search.input]
name = "sites"
pre = ""
```
**Bing**:
```toml
[Params.widgets.search]
url = "https://www.bing.com/search"
[Params.widgets.search.input]
name = "q1"
pre = "site:"
```
**Google PSE**:
```toml
[Params.widgets.search]
url = "/search/"
[Params.widgets.search.input]
name = false
pre = ""
```
Note that Google PSE requires additional steps to work correctly.
See [Creating a Programmable Search Engine](https://developers.google.com/custom-search/docs/tutorial/creatingcse) and
especially our [FAQ]({{< relref "/docs/faq.md" >}} "Mainroad FAQ") for more instructions.
### Menus
**Mainroad** supports multiple menus. The `main` menu is fully responsive and displayed right under the site header. The
secondary menus `side` and `footer` are displayed in a sidebar widget and the page footer respectively. To add a page to
a menu, add a `menu: <menu>` parameter to the page's front matter:
```yaml
menu: main # Add page to a main menu
```
**Note:** Don't forget to enable the `sidemenu` widget in the `widgets` configuration param if you want to use the
`side` menu.
---
You can also add a page to multiple menus by providing a list:
```yaml
# Add page to a main, side, and footer menu
menu:
- main
- side
- footer
```
**Note:** Please keep in mind that Mainroad menus don't support nested items i.e. submenus.
See [Menus](https://gohugo.io/content-management/menus/#readout) from official Hugo documentation for more info.
### Custom Google Fonts support
Mainroad uses Open Sans from Google Fonts as a main font. But you can use any other font from Google Fonts if you'd
like. Beware, in most cases, such changes require manual CSS adjustment because every set of fonts is different and
might not look as good as our default font.
Follow the procedure below.
1. Open Google Fonts, choose font(s) that you prefer and copy href font link. For this particular example, we choose
[Roboto with 3 different styles](https://fonts.google.com/share?selection.family=Roboto:ital,wght@0,400;0,700;1,400;1,700).
Our href font link:
```
https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,400;0,700;1,400&display=swap
```
1. Set `googleFontsLink` site's config param value to your href font link. For example:
```toml
[Params]
googleFontsLink = "https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,400;0,700;1,400&display=swap"
```
1. Override default font-family set(s):
```toml
[Params.style.vars]
fontFamilyPrimary = "'Roboto', sans-serif"
```
---
It is possible to disable Google Fonts and use system font stack instead.
1. Disable Google Fonts include. Set `googleFontsLink` site's config param value to `false`:
```toml
[Params]
googleFontsLink = false
```
1. Override font-family sets:
```toml
[Params.style.vars]
# Override font-family sets. Take care of different quotes OR escaping symbols in these params if necessary
fontFamilyPrimary = "system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', 'Liberation Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'"
# Secondary font-family set responsible for pre, code, kbd, and samp tags font
fontFamilySecondary = "SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace"
```
[Edit this page on GitHub](https://github.com/vimux/mainroad/blob/master/exampleSite/content/docs/customization.md)

View file

@ -0,0 +1,132 @@
---
title: Frequently asked questions (FAQ)
description: Browse this FAQ page to find answers to frequently asked questions that have not been covered elsewhere in
the documentation.
date: 2022-01-24T14:00:00.000Z
authorbox: false
sidebar: false
pager: false
weight: 3
menu:
main:
name: FAQ
---
Browse this FAQ page to find answers to frequently asked questions that have not been covered elsewhere
in the documentation.
<!--more-->
The answers have been categorized into two groups:
1. Answers to general questions without any lines of code.
2. Answers to technical questions with code snippets, step-by-step instructions, etc.
## General questions
### Do I need to have prior experience before proceeding with the Mainroad theme?
**Yes.** You'll need to be familiar with Hugo before proceeding.
[Our docs section]({{< ref "/docs/_index.md" >}} "Mainroad theme documentation") is intended for intermediate to
advanced users and developers. Our documentation may still be helpful to users with minimal experience, but are not
comprehensive.
### Do I need to use the extended version of Hugo?
**No.** Mainroad theme intentionally does not use any features of the extended version. As such, the extended version of
Hugo is not required (but applicable).
### Is there a list of all possible configuration options?
**Configuration:**
* See [All Configuration Settings](https://gohugo.io/getting-started/configuration/#all-configuration-settings)
for the full list of Hugo-defined variables with their default values.
* See [Mainroad config.toml example](https://github.com/Vimux/Mainroad#configtoml-example) for the full list of
Mainroad-specific variables.
**Front Matter:**
* See [Front Matter Variables](https://gohugo.io/content-management/front-matter#front-matter-variables) for the
list of Hugo-defined Front Matter variables.
* See [Mainroad Front Matter example](https://github.com/Vimux/Mainroad#front-matter-example) for the list of
Mainroad-specific Front Matter variables.
### What if I have more questions? Should I create an issue?
**We don't provide personal technical support.** As stated in our
[contributing guidelines](https://github.com/Vimux/Mainroad/blob/master/CONTRIBUTING.md), please do not use the issue
tracker for personal support. This includes reports like: “How do I do this", “Everything is broken; help me”, “I
changed something, and it doesn't work anymore”, “It's not a personal issue, but I just want to ask how X or Y works”,
“I forked your theme, then something broke; fix this immediately”, and so on.
**The issue tracker should only be used for bug reports, feature requests, and discussions that comply with our
contributing rules**. All other issues will be closed and marked as invalid.
## Technical questions
### I want to get the `favicon.ico` and `apple-touch-icon.png` to match my `hightlightColor`. What should I do?
There is no way to do this on the fly with Hugo, but you can use the one-liners below with some preparations:
1. Copy:
* `./themes/mainroad/static/favicon.ico` to `./static/favicon.ico`
* `./themes/mainroad/static/apple-touch-icon.png` to `./static/apple-touch-icon.png`
1. At the beginning of each script, replace the color in the variable with your preferred color. You must use
six-digit hex triplet notation (e.g., `#E22D30`) to make it work properly.
Go to the root of your project directory in the terminal and execute these two commands accordingly.
```
a=#E22D30;a=\\x${a:5:2}\\x${a:3:2}\\x${a:1:2};for i in 98 274 578;do printf $a|dd of=static/favicon.ico bs=1 seek=$i conv=notrunc;done
```
```
a=#E22D30;a=$(echo 504C54452A2A2A${a:1:6}|sed -e 's/../\\x&/g');printf $a|gzip|tail -c8|od -tx4 -N4 -An|xargs|sed -e 's/../\\x&/g'|printf $a$(cat -)|dd of=static/apple-touch-icon.png bs=1 seek=37 conv=notrunc
```
### I want to use Google Programmable Search Engine as a site search engine. Is it possible?
**Yes, it is possible to use [Google PSE (CSE)](https://developers.google.com/custom-search/docs/overview) as a site
search engine.**
1. Create a new search engine with [Google PSE](https://programmablesearchengine.google.com/about/). Google account
required.
1. Add a new layout.
Create file `./layouts/search/index.html` with the following content:
```
{{ define "main" }}
<script async src="https://cse.google.com/cse.js?cx=YOUR_PSE_ENGINE_ID"></script>
<div class="gcse-search"></div>
{{ end }}
```
Don't forget to paste your Google PSE ID.
1. Add search page by creating file `./content/search.md` with the following content:
```
---
title: Search
authorbox: false
sidebar: false
pager: false
---
```
1. Optional. If you use the search widget, don't forget to change the search box parameters:
```toml
[Params.widgets.search]
url = "/search/"
input.name = false
input.pre = ""
```
Google PSE (CSE) should work when it's done. Look and feel will be far from perfect, but you have to solve this problem
with [Google PSE Control Panel](https://programmablesearchengine.google.com/controlpanel/all) and additional CSS.
[Edit this page on GitHub](https://github.com/vimux/mainroad/blob/master/exampleSite/content/docs/faq.md)

View file

@ -0,0 +1,86 @@
---
title: Getting started
description: This article helps you get started with the Mainroad theme, including installation and minimal
configuration.
lead: This article helps you get started with the Mainroad theme, including installation and minimal configuration.
date: 2022-01-24T14:00:00.000Z
tags:
- "Installation"
authorbox: false
sidebar: false
pager: false
weight: 1
menu: main
---
Welcome to the Mainroad theme documentation. This quick start guide covers Mainroad theme installation and minimal
configuration and is intended for intermediate to advanced users. To understand this guide, you need to be familiar
with the [Hugo](https://gohugo.io/) static site generator.
<!--more-->
## Installation
Before installing the **Mainroad** theme, make sure that you've
[installed **Hugo** (version 0.54.0 or later)](https://gohugo.io/getting-started/quick-start/#step-1-install-hugo) and
[created a new site](https://gohugo.io/getting-started/quick-start/#step-2-create-a-new-site). To learn how to install
Hugo, visit [Hugo Documentation](https://gohugo.io/getting-started/installing/).
There are a few ways to install a theme in Hugo. This can be done via git submodule, git clone, Hugo modules, or
by downloading the archive and manually copying the files. Three installation options are described below.
### Option A: `git submodule`
*Additional requirements: git*
If you don't plan to make significant changes to the theme but still want to track and update it, you can add it as a
[git submodule](https://git-scm.com/docs/git-submodule) by running the following command from the root directory of
your Hugo site:
```sh
git submodule add https://github.com/vimux/mainroad.git themes/mainroad
```
**Note:**
[Netlify expects git submodule](https://docs.netlify.com/configure-builds/common-configurations/hugo/#hugo-themes)
instead of git clone.
### Option B: `git clone`
*Additional requirements: git*
Run this [git clone](https://git-scm.com/docs/git-clone) command from the root of your Hugo site:
```sh
git clone https://github.com/vimux/mainroad.git themes/mainroad
```
### Option C: Manual install
If you do not want to use git, you can manually
**[download ZIP](https://github.com/vimux/mainroad/archive/master.zip)** and extract it into the `themes/mainroad`
within your Hugo site.
---
### Activate theme
Whichever installation option you choose, don't forget to edit `theme` param of the site configuration `config.toml`:
```toml
theme = "mainroad"
```
To check it out, build the site via `hugo` command or make it available on a local server via `hugo server`.
## Minimal configuration
**Do not copy the [example config](https://github.com/vimux/mainroad#configtoml-example) as-is.**
Use only the parameters that you need. The Mainroad theme contains required defaults, so you don't need to add all of
the configuration parameters to run the theme for the first time. Before adding any theme-specific parameters, make
sure to edit the `theme` param inside the config file and check that the theme works.
For information about common customization settings, see [Customization page]({{< relref "/docs/customization.md" >}} "Mainroad theme customization").
To view our example configuration, visit [demo config](https://github.com/vimux/mainroad/blob/master/exampleSite/config.toml).
[Edit this page on GitHub](https://github.com/vimux/mainroad/blob/master/exampleSite/content/docs/getting-started.md)

View file

@ -0,0 +1,170 @@
---
title: Basic HTML Elements
description: Example test article that contains basic HTML elements for text formatting on the Web.
date: 2018-04-16
categories:
- "Development"
tags:
- "HTML"
- "CSS"
- "Basic Elements"
menu:
main:
name: Basic Elements
weight: 4
---
The main purpose of this article is to make sure that all basic HTML Elements are decorated with CSS so as to not miss any possible elements when creating new themes for Hugo.
<!--more-->
## Headings
Let's start with all possible headings. The HTML `<h1>``<h6>` elements represent six levels of section headings. `<h1>` is the highest section level and `<h6>` is the lowest.
# Heading 1
## Heading 2
### Heading 3
#### Heading 4
##### Heading 5
###### Heading 6
***
## Paragraph
According to the [HTML5 specification](https://www.w3.org/TR/html5/dom.html#elements) by [W3C](https://www.w3.org/), **HTML documents consist of a tree of elements and text**. Each element is denoted in the source by a [start tag](https://www.w3.org/TR/html5/syntax.html#syntax-start-tags), such as `<body>`, and an [end tag](https://www.w3.org/TR/html5/syntax.html#syntax-end-tags), such as `</body>`. (*Certain start tags and end tags can in certain cases be omitted and are implied by other tags.*)
Elements can have attributes, which control how the elements work. For example, hyperlink are formed using the `a` element and its `href` attribute.
## List Types
### Ordered List
1. First item
2. Second item
3. Third item
### Unordered List
* List item
* Another item
* And another item
### Nested list
<ul>
<li>First item</li>
<li>Second item
<ul>
<li>Second item First subitem</li>
<li>Second item second subitem
<ul>
<li>Second item Second subitem First sub-subitem</li>
<li>Second item Second subitem Second sub-subitem</li>
<li>Second item Second subitem Third sub-subitem</li>
</ul>
</li>
<li>Second item Third subitem
<ol>
<li>Second item Third subitem First sub-subitem</li>
<li>Second item Third subitem Second sub-subitem</li>
<li>Second item Third subitem Third sub-subitem</li>
</ol>
</ul>
</li>
<li>Third item</li>
</ul>
### Definition List
HTML also supports definition lists.
<dl>
<dt>Blanco tequila</dt>
<dd>The purest form of the blue agave spirit...</dd>
<dt>Reposado tequila</dt>
<dd>Typically aged in wooden barrels for between two and eleven months...</dd>
</dl>
## Blockquotes
The blockquote element represents content that is quoted from another source, optionally with a citation which must be within a `footer` or `cite` element, and optionally with in-line changes such as annotations and abbreviations.
> Quoted text.
> This line is part of the same quote.
> Also you can *put* **Markdown** into a blockquote.
Blockquote with a citation.
<blockquote>
<p>My goal wasn't to make a ton of money. It was to build good computers. I only started the company when I realized I could be an engineer forever.</p>
<footer><cite>Steve Wozniak</cite></footer>
</blockquote>
According to Mozilla's website, <q cite="https://www.mozilla.org/en-US/about/history/details/">Firefox 1.0 was released in 2004 and became a big success.</q>
## Tables
Tables aren't part of the core Markdown spec, but Hugo supports them.
| ID | Make | Model | Year |
| --- | --------- | ------- | ---- |
| 1 | Honda | Accord | 2009 |
| 2 | Toyota | Camry | 2012 |
| 3 | Hyundai | Elantra | 2010 |
Colons can be used to align columns.
| Tables | Are | Cool |
|:----------- |:-------------:| ------------:|
| align: left | align: center | align: right |
| align: left | align: center | align: right |
| align: left | align: center | align: right |
You can also use inline Markdown.
| Inline | Markdown | In | Table |
| ---------- | --------- | ----------------- | ---------- |
| *italics* | **bold** | ~~strikethrough~~ | `code` |
## Code
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example HTML5 Document</title>
</head>
<body>
<p>Test</p>
</body>
</html>
```
{{< highlight html >}}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example HTML5 Document</title>
</head>
<body>
<p>Test</p>
</body>
</html>
{{< /highlight >}}
## Other stuff — abbr, sub, sup, kbd, etc.
<abbr title="Graphics Interchange Format">GIF</abbr> is a bitmap image format.
H<sub>2</sub>O
C<sub>6</sub>H<sub>12</sub>O<sub>6</sub>
X<sup>n</sup> + Y<sup>n</sup> = Z<sup>n</sup>
Press <kbd>X</kbd> to win. Or press <kbd><kbd>CTRL</kbd>+<kbd>ALT</kbd>+<kbd>F</kbd></kbd> to show FPS counter.
<mark>As a unit of information in information theory, the bit has alternatively been called a shannon</mark>, named after Claude Shannon, the founder of field of information theory.

View file

@ -0,0 +1,85 @@
---
title: Getting Started with Hugo
date: 2014-04-02
tags:
- "go"
- "golang"
- "hugo"
- "development"
categories:
- "Development"
- "golang"
---
## Step 1. Install Hugo
Go to [Hugo releases](https://github.com/spf13/hugo/releases) and download the
appropriate version for your OS and architecture.
Save it somewhere specific as we will be using it in the next step.
More complete instructions are available at [Install Hugo](https://gohugo.io/getting-started/installing/)
## Step 2. Build the Docs
Hugo has its own example site which happens to also be the documentation site
you are reading right now.
Follow the following steps:
1. Clone the [Hugo repository](https://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:
git clone https://github.com/spf13/hugo
cd hugo
/path/to/where/you/installed/hugo server --source=./docs
> 29 pages created
> 0 tags index created
> in 27 ms
> Web Server is available at http://localhost:1313
> Press ctrl+c to stop
Once you've gotten here, follow along the rest of this page on your local build.
## Step 3. Change the docs site
Stop the Hugo process by hitting Ctrl+C.
Now we are going to run hugo again, but this time with hugo in watch mode.
/path/to/hugo/from/step/1/hugo server --source=./docs --watch
> 29 pages created
> 0 tags index created
> in 27 ms
> Web Server is available at http://localhost:1313
> 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 files are found in `docs/content/`. Unless otherwise specified, files
are located at the same relative location as the url, in our case
`docs/content/overview/quickstart.md`.
Change and save this file.. Notice what happened in your terminal.
> Change detected, rebuilding site
> 29 pages created
> 0 tags index created
> in 26 ms
Refresh the browser and observe that the typo is now fixed.
Notice how quick that was. Try to refresh the site before it's finished building. I double dare you.
Having nearly instant feedback enables you to have your creativity flow without waiting for long builds.
## Step 4. Have fun
The best way to learn something is to play with it.

View file

@ -0,0 +1,343 @@
---
title: "(Hu)go Template Primer"
date: 2014-04-02
thumbnail: "img/placeholder.png"
tags:
- "go"
- "golang"
- "templates"
- "themes"
- "development"
categories:
- "Development"
- "golang"
---
Hugo uses the excellent [Go][] [html/template][gohtmltemplate] library for
its template engine. It is an extremely lightweight engine that provides a very
small amount of logic. In our experience that it is just the right amount of
logic to be able to create a good static website. If you have used other
template systems from different languages or frameworks you will find a lot of
similarities in Go templates.
<!--more-->
This document is a brief primer on using Go templates. The [Go docs][gohtmltemplate]
provide more details.
## Introduction to Go Templates
Go templates provide an extremely simple template language. It adheres to the
belief that only the most basic of logic belongs in the template or view layer.
One consequence of this simplicity is that Go templates parse very quickly.
A unique characteristic of Go templates is they are content aware. Variables and
content will be sanitized depending on the context of where they are used. More
details can be found in the [Go docs][gohtmltemplate].
## Basic Syntax
Golang templates are HTML files with the addition of variables and
functions.
**Go variables and functions are accessible within {{ }}**
Accessing a predefined variable "foo":
{{ foo }}
**Parameters are separated using spaces**
Calling the add function with input of 1, 2:
{{ add 1 2 }}
**Methods and fields are accessed via dot notation**
Accessing the Page Parameter "bar"
{{ .Params.bar }}
**Parentheses can be used to group items together**
{{ if or (isset .Params "alt") (isset .Params "caption") }} Caption {{ end }}
## Variables
Each Go template has a struct (object) made available to it. In hugo each
template is passed either a page or a node struct depending on which type of
page you are rendering. More details are available on the
[variables](/layout/variables) page.
A variable is accessed by referencing the variable name.
<title>{{ .Title }}</title>
Variables can also be defined and referenced.
{{ $address := "123 Main St."}}
{{ $address }}
## Functions
Go template ship with a few functions which provide basic functionality. The Go
template system also provides a mechanism for applications to extend the
available functions with their own. [Hugo template
functions](/layout/functions) provide some additional functionality we believe
are useful for building websites. Functions are called by using their name
followed by the required parameters separated by spaces. Template
functions cannot be added without recompiling hugo.
**Example:**
{{ add 1 2 }}
## Includes
When including another template you will pass to it the data it will be
able to access. To pass along the current context please remember to
include a trailing dot. The templates location will always be starting at
the /layout/ directory within Hugo.
**Example:**
{{ template "chrome/header.html" . }}
## Logic
Go templates provide the most basic iteration and conditional logic.
### Iteration
Just like in Go, the Go templates make heavy use of range to iterate over
a map, array or slice. The following are different examples of how to use
range.
**Example 1: Using Context**
{{ range array }}
{{ . }}
{{ end }}
**Example 2: Declaring value variable name**
{{range $element := array}}
{{ $element }}
{{ end }}
**Example 2: Declaring key and value variable name**
{{range $index, $element := array}}
{{ $index }}
{{ $element }}
{{ end }}
### Conditionals
If, else, with, or, & and provide the framework for handling conditional
logic in Go Templates. Like range, each statement is closed with `end`.
Go Templates treat the following values as false:
* false
* 0
* any array, slice, map, or string of length zero
**Example 1: If**
{{ if isset .Params "title" }}<h4>{{ index .Params "title" }}</h4>{{ end }}
**Example 2: If -> Else**
{{ if isset .Params "alt" }}
{{ index .Params "alt" }}
{{else}}
{{ index .Params "caption" }}
{{ end }}
**Example 3: And & Or**
{{ if and (or (isset .Params "title") (isset .Params "caption")) (isset .Params "attr")}}
**Example 4: With**
An alternative way of writing "if" and then referencing the same value
is to use "with" instead. With rebinds the context `.` within its scope,
and skips the block if the variable is absent.
The first example above could be simplified as:
{{ with .Params.title }}<h4>{{ . }}</h4>{{ end }}
**Example 5: If -> Else If**
{{ if isset .Params "alt" }}
{{ index .Params "alt" }}
{{ else if isset .Params "caption" }}
{{ index .Params "caption" }}
{{ end }}
## Pipes
One of the most powerful components of Go templates is the ability to
stack actions one after another. This is done by using pipes. Borrowed
from unix pipes, the concept is simple, each pipeline's output becomes the
input of the following pipe.
Because of the very simple syntax of Go templates, the pipe is essential
to being able to chain together function calls. One limitation of the
pipes is that they only can work with a single value and that value
becomes the last parameter of the next pipeline.
A few simple examples should help convey how to use the pipe.
**Example 1 :**
{{ if eq 1 1 }} Same {{ end }}
is the same as
{{ eq 1 1 | if }} Same {{ end }}
It does look odd to place the if at the end, but it does provide a good
illustration of how to use the pipes.
**Example 2 :**
{{ index .Params "disqus_url" | html }}
Access the page parameter called "disqus_url" and escape the HTML.
**Example 3 :**
{{ if or (or (isset .Params "title") (isset .Params "caption")) (isset .Params "attr")}}
Stuff Here
{{ end }}
Could be rewritten as
{{ isset .Params "caption" | or isset .Params "title" | or isset .Params "attr" | if }}
Stuff Here
{{ end }}
## Context (aka. the dot)
The most easily overlooked concept to understand about Go templates is that {{ . }}
always refers to the current context. In the top level of your template this
will be the data set made available to it. Inside of a iteration it will have
the value of the current item. When inside of a loop the context has changed. .
will no longer refer to the data available to the entire page. If you need to
access this from within the loop you will likely want to set it to a variable
instead of depending on the context.
**Example:**
{{ $title := .Site.Title }}
{{ range .Params.tags }}
<li> <a href="{{ $baseurl }}/tags/{{ . | urlize }}">{{ . }}</a> - {{ $title }} </li>
{{ end }}
Notice how once we have entered the loop the value of {{ . }} has changed. We
have defined a variable outside of the loop so we have access to it from within
the loop.
# Hugo Parameters
Hugo provides the option of passing values to the template language
through the site configuration (for sitewide values), or through the meta
data of each specific piece of content. You can define any values of any
type (supported by your front matter/config format) and use them however
you want to inside of your templates.
## Using Content (page) Parameters
In each piece of content you can provide variables to be used by the
templates. This happens in the [front matter](/content/front-matter).
An example of this is used in this documentation site. Most of the pages
benefit from having the table of contents provided. Sometimes the TOC just
doesn't make a lot of sense. We've defined a variable in our front matter
of some pages to turn off the TOC from being displayed.
Here is the example front matter:
```
---
title: "Permalinks"
date: "2013-11-18"
aliases:
- "/doc/permalinks/"
groups: ["extras"]
groups_weight: 30
notoc: true
---
```
Here is the corresponding code inside of the template:
{{ if not .Params.notoc }}
<div id="toc" class="well col-md-4 col-sm-6">
{{ .TableOfContents }}
</div>
{{ end }}
## Using Site (config) Parameters
In your top-level configuration file (eg, `config.yaml`) you can define site
parameters, which are values which will be available to you in chrome.
For instance, you might declare:
```yaml
params:
CopyrightHTML: "Copyright &#xA9; 2013 John Doe. All Rights Reserved."
TwitterUser: "spf13"
SidebarRecentLimit: 5
```
Within a footer layout, you might then declare a `<footer>` which is only
provided if the `CopyrightHTML` parameter is provided, and if it is given,
you would declare it to be HTML-safe, so that the HTML entity is not escaped
again. This would let you easily update just your top-level config file each
January 1st, instead of hunting through your templates.
```
{{if .Site.Params.CopyrightHTML}}<footer>
<div class="text-center">{{.Site.Params.CopyrightHTML | safeHtml}}</div>
</footer>{{end}}
```
An alternative way of writing the "if" and then referencing the same value
is to use "with" instead. With rebinds the context `.` within its scope,
and skips the block if the variable is absent:
```
{{with .Site.Params.TwitterUser}}<span class="twitter">
<a href="https://twitter.com/{{.}}" rel="author">
<img src="/images/twitter.png" width="48" height="48" title="Twitter: {{.}}"
alt="Twitter"></a>
</span>{{end}}
```
Finally, if you want to pull "magic constants" out of your layouts, you can do
so, such as in this example:
```
<nav class="recent">
<h1>Recent Posts</h1>
<ul>{{range first .Site.Params.SidebarRecentLimit .Site.Recent}}
<li><a href="{{.RelPermalink}}">{{.Title}}</a></li>
{{end}}</ul>
</nav>
```
[go]: https://golang.org/
[gohtmltemplate]: https://golang.org/pkg/html/template/

@ -0,0 +1 @@
Subproject commit 65025d6d6cfffcbf77cb4bcd6c1b52a6f07d7b2e