Add wercker tutorial as example for reviewers

This commit is contained in:
Ryan Watters 2017-02-19 16:45:08 -06:00
parent ec3c19975d
commit 16513c9a62
52 changed files with 530 additions and 140 deletions

View File

@ -22,7 +22,7 @@ To prevent unnecessary delays in delivering pages to end users, dynamic site gen
Hugo and other static site generators take caching a step further. All HTML files are rendered on your computer. You can review the files before you copy them to the computer hosting the HTTP server. Since the HTML files aren't generated dynamically, we say that Hugo is a "static site generator."
Not running a web site generator on your HTTP server has many benefits. The most noticeable is performance---HTTP servers are very good at
Not running a website generator on your HTTP server has many benefits. The most noticeable is performance---HTTP servers are very good at
sending files. So good that you can effectively serve the same number
of pages with a fraction of the memory and CPU needed for a dynamic site.

View File

@ -34,26 +34,34 @@ The single parameter to `ref` is a string with a content _document name_ (`about
The _document name_ is the name of a document including the format extension; this may be just the filename, or the relative path from the `content/` directory. With a document `content/blog/post.md`, either format will produce the same result.
{{</* relref "blog/post.md" */>}} ⇒ `/blog/post/`
{{</* relref "post.md" */>}} ⇒ `/blog/post/`
```golang
{{</* relref "blog/post.md" */>}} ⇒ `/blog/post/`
{{</* relref "post.md" */>}} ⇒ `/blog/post/`
```
If you have multiple sections with the same filename, you should only use the relative path format, because the behaviour is _undefined_. So, if I also have a document `link/post.md`, the output of `ref` is unknown for `post.md`.
{{</* relref "blog/post.md" */>}} ⇒ `/blog/post/`
{{</* relref "post.md" */>}} ⇒ `/blog/post/` (maybe)
{{</* relref "post.md" */>}} ⇒ `/link/post/` (maybe)
{{</* relref "link/post.md" */>}} ⇒ `/link/post/`
```golang
{{</* relref "blog/post.md" */>}} ⇒ `/blog/post/`
{{</* relref "post.md" */>}} ⇒ `/blog/post/` (maybe)
{{</* relref "post.md" */>}} ⇒ `/link/post/` (maybe)
{{</* relref "link/post.md" */>}} ⇒ `/link/post/`
```
A relative document name must *not* begin with a slash (`/`).
{{</* relref "/blog/post.md" */>}} ⇒ `""`
```golang
{{</* relref "/blog/post.md" */>}} ⇒ `""`
```
### Anchors
When an _anchor_ is provided by itself, the current pages unique identifier will be appended; when an _anchor_ is provided with a document name, the found page's unique identifier will be appended.
{{</* relref "#who" */>}} ⇒ `#who:9decaf7`
{{</* relref "blog/post.md#who" */>}} ⇒ `/blog/post/#who:badcafe`
```golang
{{</* relref "#who" */>}} ⇒ `#who:9decaf7`
{{</* relref "blog/post.md#who" */>}} ⇒ `/blog/post/#who:badcafe`
```
More information about document unique identifiers and headings can be found [below]({{< ref "#hugo-heading-anchors" >}}).
@ -74,10 +82,12 @@ Ensuring heading uniqueness across the site is accomplished with a unique identi
`ref` and `relref` were added so you can make these reference links without having to know the documents unique identifier. (The links in document tables of contents are automatically up-to-date with this value.)
{{</* relref "extras/crossreferences.md#hugo-heading-anchors" */>}}
/extras/crossreferences/#hugo-heading-anchors:77cd9ea530577debf4ce0f28c8dca242
```golang
{{</* relref "content-management/crossreferences.md#hugo-heading-anchors" */>}}
/content-management/crossreferences/#hugo-heading-anchors:77cd9ea530577debf4ce0f28c8dca242
```
> What follows is a deeper discussion of *why* and *how* Hugo generates heading anchors. It is not necessary to know this to use `ref` and `relref`, but it may be useful in understanding how some anchors may not match your expectations.
What follows is a deeper discussion of *why* and *how* Hugo generates heading anchors. It is not necessary to know this to use `ref` and `relref`, but it may be useful in understanding how some anchors may not match your expectations.
### How to Generate a Heading Anchor

View File

@ -39,11 +39,59 @@ Documentation is an integral part of any open source project. The Hugo docs were
### Example Site Code Block
## Blockquotes
## Admonition Short Codes
### Note Shortcode
**Admonitions** are a common in technical documentation. The most popular is that seen in [reStructuredTex Directives][sourceforge]. From the SourceForge documentation:
### Warning Shortcode
> Admonitions are specially marked "topics" that can appear anywhere an ordinary body element can. They contain arbitrary body elements. Typically, an admonition is rendered as an offset block in a document, sometimes outlined or shaded, with a title matching the admonition type. - [SourceForge][sourceforge]
{{% note "Admonitions are **NOT** Blockquotes" %}}
Previous versions of the Hugo documentation used [Markdown `<blockquote>` syntax](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#blockquotes) to draw attention to content. This is not the [intended semantic use of the `<blockquote>` element](http://html5doctor.com/cite-and-blockquote-reloaded/).
{{% /note %}}
### Note Admonition Shortcode
Use the `note` shortcode when you want to draw attention to information subtly. `note` is intended to be less of an interruption in content than is `warning`.
#### Example `note` Admonition Shortcode Input
{{% input "example-note-with-heading.md" %}}
```golang
{{%/* note "Example Note Admonition" */%}}
Here is a piece of information I would like to draw your **attention** to.
{{%/* /note */%}}
```
{{% /input %}}
#### Examle `note` Admonition Shortcode Output
{{% note "Example Note Admonition" %}}
Here is a piece of information I would like to draw your **attention** to.
{{% /note %}}
### Warning Admonition Shortcode
Use the `warning` shortcode when you want to draw the user's attention
#### Example `warning` Admonition Shortcode Input
{{% input "example-note.md" %}}
```golang
{{%/* warning "Example Warning" */%}}
This is a warning, which should be reserved for *important* information like breaking changes, bad practices, etc.
{{%/* /warning */%}}
```
{{% /input %}}
#### Example `warning` Admonition Shortcode Output
{{% warning "Example Warning" %}}
This is a warning, which should be reserved for *important* information like breaking changes, bad practices, etc.
{{% /warning %}}
## Example Site Shortcodes
@ -51,11 +99,17 @@ Documentation is an integral part of any open source project. The Hugo docs were
### Example Front Matter Shortcode
## Style Guide
## Editorial Style Guide
### How Content is Ordered in the Docs
The Hugo docs are not especially prescriptive in terms of grammar and usage. We encourage everyone to contribute, regardless of your writing style. **It's more important to contribute *some* documentation than no documentation at all**. That said, here are a few pointers to help the project maintain more consistency:
### Visual Style Samples
## How Content is Ordered in the Docs
## Be Mindful of Aliases
Use aliases sparingly. The following table shows a list of all the aliases used in the Hugo Docs. If you need to use an alias in your new content file's front matter, be sure to check here first.
{{< allaliases >}}
[sourceforge]: http://docutils.sourceforge.net/docs/ref/rst/directives.html#admonitions

View File

@ -10,7 +10,7 @@ tags: [multilingual,i18n,urls]
categories: [functions]
toc: false
draft: false
aliases: [/functions/absLangUrl/]
aliases: []
notesforauthors:
---

View File

@ -10,7 +10,7 @@ tags: [dates,time]
categories: [functions]
toc: false
draft: false
aliases: [/functions/dateFormat/]
aliases: []
notesforauthors:
---

View File

@ -10,7 +10,7 @@ tags: []
categories: [functions]
toc: false
draft: false
aliases: [/functions/echoParam/]
aliases: []
notesforauthors:
---

View File

@ -10,7 +10,7 @@ tags: []
categories: [functions]
toc: false
draft: false
aliases: [/functions/hasPrefix/]
aliases: []
notesforauthors:
---

View File

@ -10,7 +10,7 @@ tags: []
categories: [functions]
toc: false
draft: false
aliases: [/functions/htmlEscape/]
aliases: []
notesforauthors:
---

View File

@ -10,7 +10,7 @@ tags: []
categories: [functions]
toc: false
draft: false
aliases: [/functions/htmlUnescape/]
aliases: []
notesforauthors:
---

View File

@ -10,7 +10,7 @@ tags: []
categories: [functions]
toc: false
draft: false
aliases: [/functions/partialCached/]
aliases: []
notesforauthors:
---

View File

@ -10,7 +10,7 @@ categories: [functions]
tags: [internationalization,multilingual,i18n,urls]
toc: false
draft: false
aliases: [/functions/relLangUrl/]
aliases: []
notesforauthors:
---

View File

@ -10,7 +10,7 @@ tags: [urls]
categories: [functions]
toc: false
draft: false
aliases: [/functions/relURL/]
aliases: []
notesforauthors:
---

View File

@ -10,7 +10,7 @@ tags: [views]
categories: [functions]
toc: false
draft: false
aliases: [/functions/Render/]
aliases: []
notesforauthors:
---

View File

@ -10,7 +10,7 @@ tags: [strings]
categories: [functions]
toc: false
draft: false
aliases: [/functions/safeHTMLAttr/]
aliases: []
notesforauthors:
---

View File

@ -10,7 +10,7 @@ tags: [strings]
categories: [functions]
toc: false
draft: false
aliases: [/functions/safeJS/]
aliases: []
notesforauthors:
---

View File

@ -11,6 +11,6 @@ categories: [functions]
weight:
toc: false
draft: false
aliases: [/functions/dot/,/functions/context/]
aliases: []
notesforauthors:
---

View File

@ -9,7 +9,7 @@ categories: [getting started]
tags: [quick start,usage]
weight: 10
draft: false
aliases: []
aliases: [/overview/quickstart/]
toc: false
notesforauthors:
---

View File

@ -1,15 +1,344 @@
---
title: Deployment with Wercker
linktitle: Deployment with Wercker
description:
description: This guide walks you through the steps needed to create a basic Hugo site, host the site's source and final website on GitHub and GitHub pages, and set up automated deployment using a free tool called Wercker.
date: 2017-02-01
publishdate: 2017-02-01
lastmod: 2017-02-01
categories: [hosting and deployment]
tags: [wercker,deployment]
authors: [Arjen Schwarz, Samuel Debruyn]
toc: false
draft: false
slug:
aliases: []
toc: true
needsreview: true
notesforauthors:
---
---
## Introduction
By the end of this guide, you will have completed the following:
* Creating a basic Hugo project and website
* Version controlling your project with Git
* Adding your project to GitHub
* Automating site deployments with a free tool called Wercker
* Deploying your website to GitHub Pages for free hosting
### Assumptions
This guide was created with the following assumptions:
1. You have a working familiarity with using Git for version control
2. You have a GitHub account
3. You have already created a basic Hugo project
If you do not meet these assumptions, the [GitHub help section][githubhelp] has an explanation of how to install and use git. [Signing up for a GitHub][ghsignup] account is free as well. If you are completely unfamiliar with creating a new Hugo website, visit the [Hugo Quick Start][quickstart].
## Creating a Basic Hugo Site
{{% note "This Guide Uses the Hugo CLI" %}}
All the work for setting up a Hugo project and using this guide is done via the Hugo CLI's most basic commands. See the [command line reference page](/developer-tools/hugo-comman-line-reference/) for a more exhaustive account of the CLI's features.
{{% /note %}}
First, create your new Hugo website using the [`hugo new site` command][basicusage] and change into the newly created directory for the project. In this guide, we are calling our new project `hugo-wercker-example`:
{{% input "hugo-new-site.sh" %}}
```bash
hugo new site hugo-wercker-example
cd hugo-wercker-example
```
{{% /input %}}
We will use the [Herring Cove theme][] by first cloning the theme into the `themes` directory.
{{% input "clone-herring-cove-theme.sh" %}}
```bash
cd themes
git clone https://github.com/spf13/herring-cove.git
```
{{% /input %}}
Cloning the project from the command line will conflict with our own version control. So, we need to remove the external git configuration that came with the clone of Herring Cove:
{{% input "remove-herring-cove-git.sh" %}}
```bash
rm -rf herring-cove/.git
```
{{% /input %}}
We need content for Hugo to build. Let's add a quick `/about` page:
```bash
hugo new about.md
```
{{% note %}}
The preceding example for the about page leverages archetypes to scaffold a new content file with preconfigured front matter. [Find out more about Hugo's archetypes](/content-management/archetypes/).
{{% /note %}}
Now you can edit `contents/about.md` in your text editor of choice, but this is not necessary for the purposes of this guide. Running the following command will build your Hugo site into the `public` directory. We have added `undraft` to ensure that the example page is no longer in draft mode:
{{% input "hugo-build-undraft.sh" %}}
```bash
hugo undraft content/about.md
```
{{% /input %}}
Once the website is build, t's a good idea to run the following command to start a local server and ensure you're changes have been implemented:
```bash
hugo server --theme=herring-cove
```
If everything is fine, you should see something similar to the image below when you go to <localhost:1313> in your browser.
![][1]
## Setting up Version Control in Git
Adding Git to your project is done by running the `git init` command from the root directory of your project.
```bash
git init
```
Running `git status` at this point will show you the following entries: the `config.toml` file, the `themes` directory, the `contents` directory, and the `public` directory. However, we don't want the `public` directory version controlled because Wercker is responsible for generating the finished website later on. Therefore, we'll add a `.gitignore` file to our project that will exclude the `/public` directory from being tracked by Git:
{{% input "gitignore.sh" %}}
```bash
echo "/public" >> .gitignore
```
{{% /input %}}
Wercker might complain when we try to build the site later on because we currently do not have any static files outside of the `themes` directory. We simply have to add *any* file to the static folder to prevent Wercker from complaining. To keep this guide simple, let's add a `robots.txt`. The following command creates the file in `/static`. The contents of the `robots.txt` lets search engines know they have full access to crawl the published website:
{{% input "addrobotstxt.sh" %}}
```bash
echo "User-agent: *\nDisallow:" > static/robots.txt
```
{{% /input %}}
Now we need to add (i.e., [stage [see Git documentation]][gitbasics]) and commit all of our changes in the repository into Git:
```bash
git commit -a -m "Initial commit"
```
## Adding the Project to GitHub
Now we need to create a new repository on GitHub. Once you are signed in to GitHub, you can add a new repository by clicking on the **&#43;&#9660;** dropdown at the top right or by going to <https://github.com/new>.
We then choose a name for the project (`hugo-wercker-example`). When clicking on create repository GitHub displays the commands for adding an existing project to the site. The commands shown below are the ones used for this site, if you're following along you will need to use the ones shown by GitHub. Once we've run those commands the project is in GitHub and we can move on to setting up the Wercker configuration. Be sure to replace `YourUserName` with your GitHub account/username:
{{% input "setup-gh-repo.sh" %}}
```bash
git remote add origin git@github.com:YourUsername/hugo-wercker-example.git
git push -u origin master
```
{{% /input %}}
![][2]
## Setting Up Wercker
To sign up for a free Wercker account, go to <https://wercker.com> and click the the **Sign Up** button on the top right of the home screen.
![][3]
### Registing for Wercker with Your GitHub Account
Sign up for Wercker using your GitHub credentials. If you don't have a GitHub account, or don't want to use it for your account, you have the option to register with a username and password as well. However, the second half of this guide---devoted to hosting your website on GitHub pages---will no longer be of interest to you.
![][4]
### Connecting GitHub or Bitbucket
After you are registered, you will need to link your GitHub or Bitbucket account to Wercker. You can link your account by navigating to your profile settings and then selecting "Git connections."
![][werckersettings]
If you registered for Wercker using GitHub, it will most likely look like the following image. To connect a missing service, click the **Connect** button, which may send you to either GitHub or Bitbucket to sign into your respective account.
![][5]
### Add Your Project
Now that we've got all the preliminaries out of the way, it's time to set up our application. For this we click on the **+ Create** button next to Applications and choose GitHub as our provider.
![][6]
### Select a Repository
When selecting GitHub, Wercker will show all your GitHub repositories. You have the option to filter repositories using the search input at the top of the repositories list. Once you have your repository selected, click the **Use selected repo** button.
![][7]
### Select the Repository Owner
In the next step, Wercker asks you to select the repository owner. Select your GitHub account and continue.
![][8]
### Configuring Access
{{% note %}}
This guide assumes you are using a public GitHub repository and understand that the [published GitHub Pages website will be available to everyone](https://help.github.com/articles/what-is-github-pages/#usage-limits).
{{%/note %}}
This step can be slightly tricky. Wercker does not have privileges to check out your private projects by default and therefore needs your permission to add a deploy key to your repository. By selecting the first option, you're simply allowing Wercker to check out the code via the same methods available to anyone visiting the project on GitHub.
![][9]
### Wercker.yml
Wercker will now attempt to create an initial `wercker.yml` file for you. More specifically, it will create a code block within the Wercker interface that you can copy to your finished file. Wercker gives us a `debian` box because our project does not have any special requirements.
Now we need to create a *wercker.yml* file in the root of our project. This file will contain our Wercker app's configuration. After we finish setting up our app, we will expand the contents of this file to build and deploy our website.
![][10]
### Public or Private
This is a personal choice. You can make an app public so that everyone can see more details about it. Keeping it private or public does not provide any overt benefits for you as the creator of the app. That said, [the app we are currently creating has been made public][publicappurl] to facilitate easier usage of this hosting and deployment guide.
![][11]
#### App Successfully Created
The application is now added and Wercker will offer you the chance to trigger a build. However, we will decline the offer because we haven't yet pushed our `wercker.yml` file to our GitHub repository.
![][12]
### Adding the Hugo-build Step
Now we need to add the Wercker steps to our build process. First, we go to the "Registry" action in the top menu. When in the registry, we can search for "hugo build". Select the "Hugo-Build by **arjen**" step.
![][13]
### Using the Hugo-build Step
A summary of very basic usage is available at the top of the details for the Hugo-Build step. Below the basic usage is the contents of the `README.md` file associated with the step's repository. `README.md`'s on Wercker usually contain more details about the advanced options and examples of usage.
We're not going to use any of the advanced features of Hugo-Build in this guide. Let's return to our project and add the first section of details we need to our `wercker.yml`.
{{% input "wercker-build-step.yml" %}}
```yaml
box: debian
build:
steps:
- arjen/hugo-build:
version: "0.14"
theme: herring-cove
flags: --buildDrafts=true
```
{{% /input %}}
{{% note "Validating Your `wercker.yml`" %}}
Wercker provides a [`wercker.yml` validation page](http://devcenter.wercker.com/articles/werckeryml/validate.html). It's usually a good idea to validate your file before committing changes, especially if you are unfamiliar with Wercker or YAML syntax.
{{% /note %}}
We can conclude this first step by pushing our `wercker.yml` to our GitHub repository and then seeing the magic at work within Wercker's interface.
{{% input "push-wecker-to-gh.sh" %}}
```bash
git commit -a -m "Add wercker.yml"
git push origin master
```
{{% /input %}}
If completed and successful, a green check mark should appear in the commit column of your first build. However, this is only the build step. We still need to deploy the website to our free hosting on GitHub Pages. If you would like more details about the build, you can click the commit hash.
![][14]
### Adding a GitHub Pages Deploy Step to `wercker.yml`
In order to deploy to GitHub Pages, we need to add a deploy step to our `wercker.yml`. We are going to add `lukevevier/gh-pages`, the most popular GitHub Pages step in the Wercker Steps repository. Additionally, we need to ensure the box Wercker uses for our deployments has git and ssh installed. We can do this using the `install-packages` command. Here is our *final* `wercker.yml` file:
{{% input "wercker.yml" %}}
```yaml
box: debian
build:
steps:
- arjen/hugo-build:
version: "0.14"
theme: herring-cove
flags: --buildDrafts=true
deploy:
steps:
- install-packages:
packages: git ssh-client
- lukevivier/gh-pages@0.2.1:
token: $GIT_TOKEN
domain: hugo-wercker.ig.nore.me
basedir: public
```
{{% /input %}}
### How does the GitHUb Pages Configuration Work?
We've provided a some important information in our `wercker.yml`. First, we've added the domain we want to use for our published website. Configuring the domain here will ensure that GitHub Pages is aware of the domain we want to use.
Secondly, we've configured the `basedir` to `public`. This is the directory that will be used as the website on GitHub Pages. `public` is also the default publishing directory in Hugo. (For more information, see [hugo's configuration docs][hugoconfig]).
Lastly, you'll notice a `$GIT_TOKEN` variable. This is used for pushing our changes to GitHub. We will need to configure this token before Wercker can build our website.
### Setting the App's Deploy Target
We can set our deploy target by going to our app's settings and clicking on **Deploy targets**. Now select **Add deploy target** and then **Custom deploy**.
![][15]
### Configuring the Deploy Step in Wercker
The next screen requires you fill in the deploy target name.
1. Make sure you enable **auto deploy** from the **master** branch.
2. Add a variable for the **GIT_TOKEN**. You'll need to create an access token in GitHub. Follow the directions in [GitHub help][accesstokenghhelp].
3. With the deploy step configured in Wercker, we can push the updated wercker.yml file to GitHub and it will create the GitHub pages site for us.
The website described in this guide is available at <http://hugo-wercker.ig.nore.me>.
![][16]
## Conclusion
Once this workflow is established, you can update your website automatically by pushing any content changes to your GitHub repository.
### Code for the Wercker Deployment Guide
[The source code for the site used in this guide is available on GitHub][guidesource], as is the [Wercker Hugo Build step][guidestep].
If you want to see an example of how you can deploy to S3 instead of GitHub pages, check [Wercker's documentation][werckerdocs] for guidance on setup.
[1]: /images/hosting-and-deployment/deployment-with-wercker/creating-a-basic-hugo-site.png
[2]: /images/hosting-and-deployment/deployment-with-wercker/adding-the-project-to-github.png
[3]: /images/hosting-and-deployment/deployment-with-wercker/wercker-sign-up.png
[4]: /images/hosting-and-deployment/deployment-with-wercker/wercker-sign-up-page.png
[5]: /images/hosting-and-deployment/deployment-with-wercker/wercker-git-connections.png
[6]: /images/hosting-and-deployment/deployment-with-wercker/wercker-add-app.png
[7]: /images/hosting-and-deployment/deployment-with-wercker/wercker-select-repository.png
[8]: /images/hosting-and-deployment/deployment-with-wercker/wercker-select-owner.png
[9]: /images/hosting-and-deployment/deployment-with-wercker/wercker-access.png
[10]: /images/hosting-and-deployment/deployment-with-wercker/werckeryml.png
[11]: /images/hosting-and-deployment/deployment-with-wercker/public-or-not.png
[12]: /images/hosting-and-deployment/deployment-with-wercker/and-we-ve-got-an-app.png
[13]: /images/hosting-and-deployment/deployment-with-wercker/wercker-search.png
[14]: /images/hosting-and-deployment/deployment-with-wercker/using-hugo-build.png
[15]: /images/hosting-and-deployment/deployment-with-wercker/adding-a-github-pages-step.png
[16]: /images/hosting-and-deployment/deployment-with-wercker/configure-the-deploy-step.png
[werckersettings]: /images/hosting-and-deployment/deployment-with-wercker/wercker-account-settings.png
[accesstokenghhelp]: https://help.github.com/articles/creating-an-access-token-for-command-line-use/
[basicusage]: /getting-started/basic-usage/
[ghsignup]: https://github.com/join
[gitbasics]: https://git-scm.com/book/en/v2/Getting-Started-Git-Basics
[githubhelp]: https://help.github.com/articles/set-up-git/
[guidesource]: https://github.com/ArjenSchwarz/hugo-wercker-example
[guidestep]: https://github.com/ArjenSchwarz/wercker-step-hugo-build
[Herring Cove theme]: https://github.com/spf13/herring-cove
[hugoconfig]: /getting-started/configuration/
[publicappurl]: https://app.wercker.com/#applications/5586dcbdaf7de9c51b02b0d5
[quickstart]: /getting-started/quick-start/
[werckerdocs]: (http://devcenter.wercker.com/docs/deploy/s3.html)

View File

@ -1,6 +1,6 @@
---
date: 2016-02-11T23:41:27+01:00
description: "Personal web site and blog of digital director Jorgen Nilsson"
description: "Personal website and blog of digital director Jorgen Nilsson"
license: ""
licenseLink: ""
sitelink: http://jorgennilsson.com/

View File

@ -15,4 +15,4 @@ toc: true
notesforauthors:
---
## Base Template Lookup Order
## Base Template Lookup Order

View File

@ -11,24 +11,25 @@ tags: [files]
draft: false
weight:
aliases: [/extras/localfiles/]
toc: false
toc: true
notesforauthors:
---
## Traversing Local Files
Using Hugo's function `readDir`,
you can traverse your web site's files on your server.
Hugo's [`readDir` function][], you can traverse your website's files on your server.
## Using _readDir_
The `readDir` function returns an array
of [`os.FileInfo`](https://golang.org/pkg/os/#FileInfo).
It takes a single, string argument: a path.
This path can be to any directory of your web site
This path can be to any directory of your website
(as found on your server's filesystem).
Whether the path is absolute or relative makes no difference,
because&mdash;at least for `readDir`&mdash;the root of your web site (typically `./public/`)
because&mdash;at least for `readDir`&mdash;the root of your website (typically `./public/`)
in effect becomes both:
1. The filesystem root; and
@ -42,7 +43,7 @@ So, let's create a new shortcode using `readDir`:
For the files in any given directory, this shortcode usefully lists the files' basenames and sizes and also creates a link to each of them.
This shortcode [has already been included in this very web site][].
This shortcode [has already been included in this very website][].
So, let's list some of its CSS files. (If you click on their names, you can reveal the contents.)
{{< directoryindex path="/static/css" pathURL="/css" >}}
@ -58,4 +59,5 @@ This is the call that rendered the above output:
The initial slash `/` in `pathURL` is important. Otherwise, `pathURL` becomes relative to the current web page.
{{% /note %}}
[has already been included in this very web site]: https://github.com/spf13/hugo/blob/master/docs/layouts/shortcodes/directoryindex.html
[has already been included in this very website]: https://github.com/spf13/hugo/blob/master/docs/layouts/shortcodes/directoryindex.html
[`readDir` function]: /functions/readdir/

View File

@ -0,0 +1,22 @@
<table class="utils-table">
<thead>
<tr>
<td>Title</td>
<td>Section</td>
<td>Aliases</td>
</tr>
</thead>
<tbody>
{{$ghrepo := add $.Site.Params.ghdocsrepo "content/"}}
{{ range $.Site.Pages.ByTitle }}
{{if .Aliases }}
{{$section := replace .Section "-" " " | title}}
<tr>
<td>{{.Title}} <a href="{{.Permalink}}" title="See Web Page"><i class="fa fa-file-o" aria-hidden="true"></i></a> <a href="{{$ghrepo}}{{.File.Path}}" title="See Source" target="_blank"> <i class="fa fa-code" aria-hidden="true"></i></a></td>
<td>{{$section}}</td>
<td><code>{{ delimit .Aliases ", " }}<code></td>
{{end}}
</tr>
{{end}}
</tbody>
</table>

View File

@ -10,7 +10,7 @@
{{- else -}}
{{$filenameclass := index (split (.Get 0) ".") 1 }}
<div class="code-copy input" id="{{.Get 0|urlize}}">
<div class="code-copy-header"><div class="action-buttons"></div><span class="filename" title="{{.Get 0}}">{{.Get 0}}</span><i class="icon-{{$filenameclass}} input"></i></div>
<div class="code-copy-header"><div class="action-buttons"></div>{{if ne $filenameclass "sh"}}<span class="filename" title="{{.Get 0}}">{{.Get 0}}</span>{{end}}<i class="icon-{{$filenameclass}} input"></i></div>
<button class="copy-button" title="Copy to clipboard" data-clipboard-snippet>
<div class="copy-text"><i class="icon-clipboard"></i> COPY</div>
</button>

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 KiB

View File

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

0
static/js/script.min.js vendored Executable file → Normal file
View File

View File

@ -27,6 +27,7 @@ $hugo-green-light:#33BA91;
//Examples
$examplesite-example-color:$hugo-pink;
$examplesite-codeblock-shortcode-header-bg-color: $hugo-pink;
$input-example-color:$hugo-gray-dark;
$output-example-color:$hugo-blue;

View File

@ -106,6 +106,7 @@
.icon-sass:before { content: '\e803'; } /* '' */
.icon-search:before { content: '\e80b'; } /* '' */
.icon-sh:before { content: '\e804'; } /* '' */
.icon-bash:before { content: '\e804'; } /* '' */
.icon-share:before { content: '\f1e0'; } /* '' */
.icon-tag:before { content: '\e806'; } /* '' */
.icon-tags:before { content: '\e805'; } /* '' */

View File

@ -1,5 +1,4 @@
.note,
.caution,
.warning {
display: block;
margin-bottom: 20px;
@ -18,6 +17,7 @@
left: -.5em;
z-index: 10;
background-color: $body-bg-color;
border-radius:30%;
}
h2 {
font-size: 1.1em;
@ -39,6 +39,10 @@
pre {
color: lighten($base-font-color, 20%);
}
em,strong {
color:inherit;
font-weight:inherit;
}
}
.shortcode-content {
display: block;
@ -55,9 +59,11 @@
.note {
border-color: $hugo-blue;
background-color: desaturate(lighten($hugo-blue,61%),20%);
&:before {
content: '\e80d';
color: $hugo-blue;
background-color: desaturate(lighten($hugo-blue,61%),20%);
}
h2 {
border-bottom-color: $hugo-blue;
@ -65,23 +71,13 @@
}
}
.caution {
border-color: $hugo-gold;
&:before {
content: '\e80f';
color: $hugo-gold;
}
h2 {
border-bottom-color: $hugo-gold;
color: $hugo-gold;
}
}
.warning {
border-color: $hugo-pink;
background-color: lighten($hugo-pink,54%);
&:before {
content: '\e810';
color: $hugo-pink;
background-color: lighten($hugo-pink,54%);
}
h2 {
border-bottom-color: $hugo-pink;
@ -91,63 +87,4 @@
color: $hugo-pink;
}
}
}
// .note,
// .caution,.warning {
// display: block;
// margin-bottom:20px;
// width: 100%;
// h2 {
// font-size: 1.1em;
// color: $hugo-white;
// width: 100%;
// display: block;
// margin: 0px;
// padding: .25em 12px;
// border: none;
// outline: none;
// code,pre {
// color:$hugo-white;
// }
// }
// .shortcode-content {
// display: block;
// margin: 0px;
// padding: 12px;
// font-size:.9em;
// }
// }
// .note {
// > h2 {
// background-color: $hugo-blue;
// }
// .shortcode-content {
// background-color: lighten($hugo-blue, 55%);
// @include MQ(retina){
// background-color: lighten($hugo-blue,56%);
// }
// }
// }
// .caution {
// > h2 {
// background-color: $hugo-gold;
// }
// .shortcode-content {
// background-color: lighten($hugo-gold, 30%);
// @include MQ(retina){
// background-color: lighten($hugo-gold,35%);
// }
// }
// }
// .warning {
// > h2 {
// background-color: $hugo-pink;
// }
// .shortcode-content {
// background-color: lighten($hugo-pink, 50%);
// @include MQ(retina){
// background-color: lighten($hugo-pink, 54%);
// }
// }
// }
}

View File

@ -32,10 +32,11 @@
font-style:normal;
}
cite.blockquote-citation {
position: absolute;
bottom: .3em;
right: .3em;
float: right;
position: relative;
display:block;
clear:both;
text-align:right;
line-height:2;
font-size: 14px;
font-style: normal;
}

View File

@ -28,26 +28,26 @@ pre {
td,
li {
code {
font-size: .85em;
font-size: .9em;
display: inline-block;
color: $inline-code-text-color;
font-family: $code-font-family;
padding-left: .25em;
padding-right: .25em;
padding-bottom: .1em;
// padding-bottom: .1em;
text-transform: none;
line-height: 1.2;
margin-bottom: .15em;
margin-top: 0px;
padding-top: 0px;
// line-height:1;
vertical-align: middle;
//darken code background color for non-retina screens
padding-top: .1em;
vertical-align: bottom;
//darken code background color for non-retina displays
background-color: darken($inline-code-background-color, 5%);
border: none;
outline: none;
z-index: -1;
@include MQ(retina) {
//lighten code background color for retina displays
background-color: $inline-code-background-color;
}
}
@ -168,7 +168,7 @@ div.code-copy-header {
background-color: $output-example-color;
}
&.examplesite {
background-color: $examplesite-example-color;
background-color: $examplesite-codeblock-shortcode-header-bg-color;
}
span.filename {
text-align: center;
@ -185,6 +185,10 @@ div.code-copy-header {
[class^="icon-"] {
color: $code-filename-color;
}
//corrects odd placement of terminal icon
i.icon-sh.input,i.icon-bash.input {
padding-right:.5em;
}
}
.action-buttons {

View File

@ -1,3 +1,22 @@
svg.svg-icon {
max-width: 60px;
}
//for lists that show good and bad examples
h2,
h3,
h4,
li {
.fa.fa-thumbs-up {
color: $hugo-green;
}
}
h2,
h3,
h4,
li {
.fa.fa-thumbs-down {
color: $hugo-pink;
}
}

View File

@ -6,8 +6,9 @@ table {
width: auto;
display: block;
border-left: 2px solid $hugo-gray;
margin:0px;
font-size:15px;
margin: 0px;
font-size: 15px;
margin-bottom:1em;
tr {
border-top: 2px solid $hugo-gray;
th,
@ -21,15 +22,15 @@ table {
}
&.terms-table {
td {
width:50%;
width: 50%;
}
}
thead {
width:100%;
width: 100%;
background-color: $hugo-black;
color:$hugo-white;
color: $hugo-white;
tr {
min-width:100%;
min-width: 100%;
th {
padding-left: 4px;
padding-right: 6px;
@ -42,15 +43,24 @@ table {
}
}
tbody {
min-width:100%;
min-width: 100%;
tr {
min-width:100%;
min-width: 100%;
background-color: $body-bg-color;
&:nth-child(even) {
background-color: $hugo-blue-ultra-light;
}
&:last-child {
border-bottom: 2px solid $hugo-gray;
border-bottom: 2px solid $hugo-gray;
}
}
}
&.utils-table {
tr {
line-height: 1.2;
font-size:.9em;
> td:first-child {
min-width: 220px;
}
}
}

View File

@ -18,7 +18,7 @@
@import 'components/lists';
@import 'components/anchors';
@import 'components/images';
@import 'components/note-caution-and-warning-shortcodes';
@import 'components/admonitions';
@import 'vendor/highlightjs';
@import 'components/code';
@import 'components/icons';