mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
Squashed 'docs/' changes from f887bd7b..1d052b16
1d052b16 Update hosting-on-netlify.md 28b96bec Remove double brackets in Netlify hosting tutorial 373ed38b Update deployment instructions from hugo > 0.20 on Netlify 1bbb41ca Generate static assets on deploy in Nanobox tutorial 816d207f Add missing backtick in templates/views.md bf88e772 Add nanobox as a deployment option 9c37b4cc Change config's syntax order matching description d3cb05a7 Fix wrongly named default value of publishDir 4be85c54 Add link to showcase a theme setup via config file 46837195 Init and update of submodules in .gitlab-ci.yml 9e7c2827 Add CSS lang argument to code block 85aad56e Abstract the type in the lookup order 4e1e43e9 Fix broken Pygments url 65b4e79b Correct GitLab project pipelines URL 94af72b5 Fix .Data.Terms usage in taxonomy template example eb371e52 functions: Fix lang.NumFmt docs a745cd6c Fix layouts' folder name in template primer e181e637 Correct typo on GitHub pages guide (#151) 28698500 Remove HTML special chars from Windows install example 96b1f5b5 Remove not needed escape slashes in urls.md 2e05043f Add upgrade instructions using homebrew 2a14624d Fix alias in countrunes.md 5e26bb97 Update docker image for build/publish 01424887 List the internal templates a3ef5be9 Remove string concatenation from add (math) sample 43d12b44 Fix typo 89bafa49 Change to Asciidoc URI 4e14071e Removes an extra bracket (>) in single-page-templates.md 0938e423 Fix typo in http2 server push blog fac55121 Fix typo in deployment with rsync tutorial git-subtree-dir: docs git-subtree-split: 1d052b16a1290ada12f1e28c7c0c373f86741071
This commit is contained in:
parent
ec4e6f9df2
commit
7d63a23b0c
25 changed files with 322 additions and 91 deletions
|
@ -214,7 +214,7 @@ Markdown syntax is simple enough to learn in a single sitting. The following are
|
|||
* [Markdown Tutorial (Interactive), Garen Torikian][mdtutorial]
|
||||
|
||||
[`emojify` function]: /functions/emojify/
|
||||
[ascii]: http://asciidoc.org/
|
||||
[ascii]: http://asciidoctor.org/
|
||||
[bfconfig]: /getting-started/configuration/#configuring-blackfriday-rendering
|
||||
[blackfriday]: https://github.com/russross/blackfriday
|
||||
[mmark]: https://github.com/miekg/mmark
|
||||
|
|
|
@ -24,7 +24,7 @@ The default Hugo target directory for your built website is `public/`. However,
|
|||
The `permalinks` option in your [site configuration][config] allows you to adjust the directory paths (i.e., the URLs) on a per-section basis. This will change where the files are written to and will change the page's internal "canonical" location, such that template references to `.RelPermalink` will honor the adjustments made as a result of the mappings in this option.
|
||||
|
||||
{{% note "Default Publish and Content Folders" %}}
|
||||
These examples use the default values for `publishDir` and `contentDir`; i.e., `publish` and `content`, respectively. You can override the default values in your [site's `config` file](/getting-started/configuration/).
|
||||
These examples use the default values for `publishDir` and `contentDir`; i.e., `public` and `content`, respectively. You can override the default values in your [site's `config` file](/getting-started/configuration/).
|
||||
{{% /note %}}
|
||||
|
||||
For example, if one of your [sections][] is called `post` and you want to adjust the canonical path to be hierarchical based on the year, month, and post title, you could set up the following configurations in YAML and TOML, respectively.
|
||||
|
@ -149,14 +149,14 @@ Assuming a `baseURL` of `example.com`, the contents of the auto-generated alias
|
|||
<head>
|
||||
<title>https://example.com/posts/my-intended-url</title>
|
||||
<link rel="canonical" href="https://example.com/posts/my-intended-url"/>
|
||||
<meta name=\"robots\" content=\"noindex\">
|
||||
<meta name="robots" content="noindex">
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
|
||||
<meta http-equiv="refresh" content="0; url=https://example.com/posts/my-intended-url"/>
|
||||
</head>
|
||||
</html>
|
||||
```
|
||||
|
||||
The `http-equiv="refresh"` line is what performs the redirect, in 0 seconds in this case. If an end user of your website goes to `https://example.com/posts/my-old-url`, they will now be automatically redirected to the newer, correct URL. The addition of `<meta name=\"robots\" content=\"noindex\">` lets search engine bots know they they should not crawl and index your new alias page.
|
||||
The `http-equiv="refresh"` line is what performs the redirect, in 0 seconds in this case. If an end user of your website goes to `https://example.com/posts/my-old-url`, they will now be automatically redirected to the newer, correct URL. The addition of `<meta name="robots" content="noindex">` lets search engine bots know they they should not crawl and index your new alias page.
|
||||
|
||||
### Customize
|
||||
You may customize this alias page by creating an `alias.html` template in the
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
---
|
||||
title: lang.NumFmt
|
||||
description: "Formats a number with a given precision using the requested `decimal`, `grouping`, and `negative` characters."
|
||||
description: "Formats a number with a given precision using the requested `negative`, `decimal`, and `grouping` options. The `options` parameter is a string consisting of `<negative> <decimal> <grouping>`."
|
||||
godocref: ""
|
||||
workson: []
|
||||
date: 2017-02-01
|
||||
publishdate: 2017-02-01
|
||||
lastmod: 2017-02-01
|
||||
lastmod: 2017-08-21
|
||||
categories: [functions]
|
||||
#tags: [numbers]
|
||||
menu:
|
||||
docs:
|
||||
parent: "functions"
|
||||
toc: false
|
||||
signature: ["lang.NumFmt <decimal> <grouping> <negative> <precision> <number>"]
|
||||
signature: ["lang.NumFmt PRECISION NUMBER [OPTIONS]"]
|
||||
workson: []
|
||||
hugoversion:
|
||||
relatedfuncs: []
|
||||
|
@ -27,8 +27,9 @@ The default options value is `- . ,`.
|
|||
Numbers greater than or equal to 5 are rounded up. For example, if precision is set to `0`, `1.5` becomes `2`, and `1.4` becomes `1`.
|
||||
|
||||
```
|
||||
{{ lang.NumFmt "," "." "-" 2 12345.6789 }} → 12.345,68
|
||||
{{ lang.NumFmt "." "" "-" 6 -12345.6789 }} → -12345.678900
|
||||
{{ lang.NumFmt "." "," "-" 0 -12345.6789 }} → -12,346
|
||||
{{ -98765.4321 | lang.NumFmt "." "," "-" 2 }} → -98,765.43
|
||||
{{ lang.NumFmt 2 12345.6789 }} → 12,345.68
|
||||
{{ lang.NumFmt 2 12345.6789 "- , ." }} → 12.345,68
|
||||
{{ lang.NumFmt 0 -12345.6789 "- . ," }} → -12,346
|
||||
{{ lang.NumFmt 6 -12345.6789 "- ." }} → -12345.678900
|
||||
{{ -98765.4321 | lang.NumFmt 2 }} → -98,765.43
|
||||
```
|
||||
|
|
|
@ -15,7 +15,7 @@ workson: []
|
|||
hugoversion:
|
||||
relatedfuncs: []
|
||||
deprecated: false
|
||||
aliases: [/functions/countrunes/,/functions/countwords/]
|
||||
aliases: [/functions/countrunes/]
|
||||
---
|
||||
|
||||
In contrast with `countwords` function, which counts every word in a string, the `countrunes` function determines the number of runes in the content and excludes any whitespace. This has specific utility if you are dealing with CJK-like languages.
|
||||
|
|
|
@ -31,35 +31,3 @@ There are 6 basic mathematical operators that can be used in Hugo templates:
|
|||
| `mul` | Multiplies two integers. | `{{mul 2 3}}` → 6 |
|
||||
| `sub` | Subtracts two integers. | `{{sub 3 2}}` → 1 |
|
||||
|
||||
## Use `add` with Strings
|
||||
|
||||
You can also use the `add` function with strings. You may like this functionality in many use cases, including creating new variables by combining page- or site-level variables with other strings.
|
||||
|
||||
For example, social media sharing with [Twitter Cards][cards] requires the following `meta` link in your site's `<head>` to display Twitter's ["Summary Card with Large Image"][twtsummary]:
|
||||
|
||||
```
|
||||
<meta name="twitter:image" content="https://example.com/images/my-twitter-image.jpg">
|
||||
```
|
||||
|
||||
Let's assume you have an `image` field in the front matter of each of your content files:
|
||||
|
||||
```
|
||||
---
|
||||
title: My Post
|
||||
image: my-post-image.jpg
|
||||
---
|
||||
```
|
||||
|
||||
You can then concatenate the `image` value (string) with the path to your `images` directory in `static` and leverage a URL-related templating function for increased flexibility:
|
||||
|
||||
{{< code file="partials/head/twitter-card.html" >}}
|
||||
{{$socialimage := add "images/" .Params.image}}
|
||||
<meta name="twitter:image" content="{{ $socialimage | absURL }}">
|
||||
{{< /code >}}
|
||||
|
||||
{{% note %}}
|
||||
The `add` example above makes use of the [`absURL` function](/functions/absurl/). `absURL` and its relative companion `relURL` is the recommended way to construct URLs in Hugo.
|
||||
{{% /note %}}
|
||||
|
||||
[cards]: https://dev.twitter.com/cards/overview
|
||||
[twtsummary]: https://dev.twitter.com/cards/types/summary-large-image
|
|
@ -388,10 +388,10 @@ C:\Hugo\Sites> hugo new site example.com
|
|||
You should now have a directory at `C:\Hugo\Sites\example.com`. Change into that directory and list the contents. You should get output similar to the following:
|
||||
|
||||
```
|
||||
C:\Hugo\Sites>cd example.com
|
||||
C:\Hugo\Sites\example.com>dir
|
||||
Directory of C:\hugo\sites\example.com
|
||||
|
||||
C:\Hugo\Sites> cd example.com
|
||||
C:\Hugo\Sites\example.com> dir
|
||||
Directory of C:\hugo\sites\example.com
|
||||
|
||||
04/13/2015 10:44 PM <DIR> .
|
||||
04/13/2015 10:44 PM <DIR> ..
|
||||
04/13/2015 10:44 PM <DIR> archetypes
|
||||
|
@ -459,7 +459,7 @@ See the [related discussion in the Hugo forums][redhatforum].
|
|||
|
||||
## Upgrade Hugo
|
||||
|
||||
Upgrading Hugo is as easy as downloading and replacing the executable you’ve placed in your `PATH`.
|
||||
Upgrading Hugo is as easy as downloading and replacing the executable you’ve placed in your `PATH` or run `brew upgrade hugo` if using Homebrew.
|
||||
|
||||
## Install Pygments (Optional)
|
||||
|
||||
|
@ -481,7 +481,7 @@ Now that you've installed Hugo, read the [Quick Start guide][quickstart] and exp
|
|||
[installgit]: http://git-scm.com/
|
||||
[installgo]: https://golang.org/dl/
|
||||
[Path Editor]: https://patheditor2.codeplex.com/
|
||||
[pygments]: https://pygments.org
|
||||
[pygments]: http://pygments.org
|
||||
[quickstart]: /getting-started/quick-start/
|
||||
[redhatforum]: https://discourse.gohugo.io/t/solved-fedora-copr-repository-out-of-service/2491
|
||||
[releases]: https://github.com/gohugoio/hugo/releases
|
||||
|
|
247
content/hosting-and-deployment/deployment-with-nanobox.md
Normal file
247
content/hosting-and-deployment/deployment-with-nanobox.md
Normal file
|
@ -0,0 +1,247 @@
|
|||
---
|
||||
title: Host-Agnostic Deploys with Nanobox
|
||||
linktitle: Host-Agnostic Deploys with Nanobox
|
||||
description: Easily deploy Hugo to AWS, DigitalOcean, Google, Azure, and more...
|
||||
date: 2017-08-24
|
||||
publishdate: 2017-08-24
|
||||
lastmod: 2017-08-24
|
||||
categories: [hosting and deployment]
|
||||
#tags: [nanobox,deployment,hosting,aws,digitalocean,azure,google,linode]
|
||||
authors: [Steve Domino]
|
||||
menu:
|
||||
docs:
|
||||
parent: "hosting-and-deployment"
|
||||
weight: 05
|
||||
weight: 05
|
||||
sections_weight: 05
|
||||
draft: false
|
||||
aliases: [/tutorials/deployment-with-nanobox/]
|
||||
toc: true
|
||||
---
|
||||
|
||||
![hugo with nanobox](/images/hosting-and-deployment/deployment-with-nanobox/hugo-with-nanobox.png)
|
||||
|
||||
## Before You Begin
|
||||
|
||||
Nanobox provides an entire end-to-end workflow for developing and deploying applications. Using Nanobox to deploy also means you'll use it to develop your application.
|
||||
|
||||
{{% note %}}
|
||||
If you're already using Nanobox and just need deployment instructions, you can skip to [Deploying Hugo with Nanobox](#deploying-hugo-with-nanobox)
|
||||
{{% /note %}}
|
||||
|
||||
|
||||
## What You'll Need
|
||||
|
||||
With Nanobox you don't need to worry about having Golang or Hugo installed. They'll be installed as part of the development environment created for you.
|
||||
|
||||
To get started you'll just need the following three items:
|
||||
|
||||
* [A Nanobox Account](https://nanobox.io) - Signup is free
|
||||
* [Nanobox Desktop](https://dashboard.nanobox.io/download) - The free desktop development tool
|
||||
* An account with a hosting provider such as:
|
||||
- [AWS](https://aws.amazon.com/)
|
||||
- [DigitalOcean](https://www.digitalocean.com/)
|
||||
- [Linode](https://www.linode.com/)
|
||||
- Azure (coming)
|
||||
- Google (coming)
|
||||
- [Roll Your Own](https://docs.nanobox.io/providers/create/)
|
||||
|
||||
### Before We Begin
|
||||
|
||||
There are a few things to get out of the way before diving into the guide. To deploy, you'll need to make sure you have connected a host account to your Nanobox account, and launched a new application.
|
||||
|
||||
#### Connect a Host Account
|
||||
|
||||
Nanobox lets you choose where to host your application (AWS, DigitalOcean, Google, Azure, etc.). In the [Hosting Accounts](https://dashboard.nanobox.io/provider_accounts) section of your Nanobox dashboard [link your Nanobox account with your host](https://docs.nanobox.io/providers/hosting-accounts/).
|
||||
|
||||
#### Launch a New Application on Nanobox
|
||||
|
||||
[Launching a new app on Nanobox](https://docs.nanobox.io/workflow/launch-app/) is very simple. Navigate to [Launch New App](https://dashboard.nanobox.io/apps/new) in the dashboard, and follow the steps there. You'll be asked to name your app, and select a host and region.
|
||||
|
||||
With those out of the way you're ready to get started!
|
||||
|
||||
|
||||
## Getting Started
|
||||
|
||||
{{% note %}}
|
||||
If you already have a functioning Hugo app, you can skip to [Configure Hugo to run with Nanobox](#configure-hugo-to-run-with-nanobox)
|
||||
{{% /note %}}
|
||||
|
||||
To get started, all you'll need an empty project directory. Create a directory wherever you want your application to live and `cd` into it:
|
||||
|
||||
`mkdir path/to/project && cd path/to/project`
|
||||
|
||||
### Configure Hugo to run with Nanobox
|
||||
|
||||
Nanobox uses a simple config file known as a [boxfile.yml](https://docs.nanobox.io/boxfile/) to describe your application's infrastructure. In the root of your project add the following `boxfile.yml`:
|
||||
|
||||
{{< code file="boxfile.yml" >}}
|
||||
run.config:
|
||||
|
||||
# use the static engine
|
||||
engine: static
|
||||
engine.config:
|
||||
|
||||
# tell the engine where to serve static assets from
|
||||
rel_dir: public
|
||||
|
||||
# enable file watching for live reload
|
||||
fs_watch: true
|
||||
|
||||
# install hugo
|
||||
extra_steps:
|
||||
- bash ./install.sh
|
||||
|
||||
deploy.config:
|
||||
|
||||
# generate site on deploy
|
||||
extra_steps:
|
||||
- hugo
|
||||
|
||||
{{< /code >}}
|
||||
|
||||
{{% note %}}
|
||||
If you already have a functioning Hugo app, which should now be configured, you can skip to [Deploying Hugo with Nanobox](#deploying-hugo-with-nanobox).
|
||||
{{% /note %}}
|
||||
|
||||
### Installing Hugo
|
||||
|
||||
Nanobox uses Docker to create instant, isolated, development environments. Because of this, you'll need to make sure that during development you have Hugo available.
|
||||
|
||||
Do this by add a custom install script at the root of your project that will install Hugo automatically for you:
|
||||
|
||||
{{< code file="install.sh" >}}
|
||||
|
||||
#!/bin/bash
|
||||
|
||||
if [[ ! -f /data/bin/hugo ]]; then
|
||||
cd /tmp
|
||||
wget https://github.com/gohugoio/hugo/releases/download/v0.25.1/hugo_0.25.1_Linux-64bit.tar.gz
|
||||
tar -xzf hugo_0.25.1_Linux-64bit.tar.gz
|
||||
mv hugo /data/bin/hugo
|
||||
cd -
|
||||
rm -rf /tmp/*
|
||||
fi
|
||||
|
||||
{{< /code >}}
|
||||
|
||||
{{% note %}}
|
||||
If the install script fails during `nanobox run` you may need to make it executable with `chmod +x install.sh`
|
||||
{{% /note %}}
|
||||
|
||||
### Generating a New Hugo App
|
||||
|
||||
You'll generate your new application from inside a Nanobox console (this is why you don't need to worry about having Golang or Hugo installed).
|
||||
|
||||
Run the following command to drop into a Nanobox console (inside the VM) where your codebase is mounted:
|
||||
|
||||
```
|
||||
nanobox run
|
||||
```
|
||||
|
||||
![nanobox run](/images/hosting-and-deployment/deployment-with-nanobox/nanobox-run.png)
|
||||
|
||||
Once inside here use the following steps to create a new Hugo application:
|
||||
|
||||
```
|
||||
# cd into the /tmp dir to create an app
|
||||
cd /tmp
|
||||
|
||||
# generate the hugo app
|
||||
hugo new site app
|
||||
|
||||
# cd back into the /app dir
|
||||
cd -
|
||||
|
||||
# copy the generated app into the project
|
||||
shopt -s dotglob
|
||||
cp -a /tmp/app/* .
|
||||
```
|
||||
|
||||
### Install a theme
|
||||
|
||||
`cd` into the `themes` directory and clone the `nanobox-hugo-theme` repo:
|
||||
|
||||
```
|
||||
cd themes
|
||||
git clone https://github.com/sdomino/nanobox-hugo-theme
|
||||
```
|
||||
|
||||
To use the theme *either* copy the entire `config.toml` that comes with the theme, or just add the theme to your existing `config.toml`
|
||||
|
||||
```
|
||||
# copy the config.toml that comes with the theme
|
||||
cp ./themes/nanobox-hugo-theme/config.toml config.toml
|
||||
|
||||
# or, add it to your existing config.toml
|
||||
theme = "nanobox-hugo-theme"
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
It is not intended that you use the `nanobox-hugo-theme` as your actual theme. It's simply a theme to start with and should be replaced.
|
||||
{{% /note %}}
|
||||
|
||||
### View Your App
|
||||
|
||||
To view your application simply run the following command from a Nanobox console:
|
||||
|
||||
```
|
||||
hugo server --bind="0.0.0.0" --baseUrl=$APP_IP
|
||||
```
|
||||
|
||||
![hugo server](/images/hosting-and-deployment/deployment-with-nanobox/hugo-server.png)
|
||||
|
||||
With that you should be able to visit your app at the given IP:1313 address
|
||||
|
||||
{{% note %}}
|
||||
You can [add a custom DNS alias](https://docs.nanobox.io/cli/dns/#add) to make it easier to access your app. Run `nanobox dns add local hugo.dev`. After starting your server, visit your app at [hugo.dev:1313](http://hugo.dev:1313)
|
||||
{{% /note %}}
|
||||
|
||||
### Develop, Develop, Develop
|
||||
|
||||
{{% note %}}
|
||||
IMPORTANT: One issue we are aware of, and actively investigating, is livereload. Currently, livereload does not work when developing Hugo applications with Nanobox.
|
||||
{{% /note %}}
|
||||
|
||||
With Hugo installed you're ready to go. Develop Hugo like you would normally (using all the generators, etc.). Once your app is ready to deploy, run `hugo` to generate your static assets and get ready to deploy!
|
||||
|
||||
|
||||
## Deploying Hugo with Nanobox
|
||||
|
||||
{{% note %}}
|
||||
If you haven't already, make sure to [connect a hosting account](#connect-a-host-account) to your Nanobox account, and [launch a new application](#launch-a-new-application-on-nanobox) in the Dashboard.
|
||||
{{% /note %}}
|
||||
|
||||
To deploy your application to Nanobox you simply need to [link your local codebase](https://docs.nanobox.io/workflow/deploy-code/#add-your-live-app-as-a-remote) to an application you've created on Nanobox. That is done with the following command:
|
||||
|
||||
```
|
||||
nanobox remote add <your-app-name>
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
You may be prompted to login using your ***Nanobox credentials*** at this time
|
||||
{{% /note %}}
|
||||
|
||||
### Stage Your Application (optional)
|
||||
|
||||
Nanobox gives you the ability to [simulate your production environment locally](https://docs.nanobox.io/workflow/deploy-code/#preview-locally). While staging is optional it's always recommended, so there's no reason not to!
|
||||
|
||||
To stage your app simply run:
|
||||
|
||||
```
|
||||
nanobox deploy dry-run
|
||||
```
|
||||
|
||||
Now visit your application with the IP address provided.
|
||||
|
||||
![nanobox deploy dry-run](/images/hosting-and-deployment/deployment-with-nanobox/nanobox-deploy-dry-run.png)
|
||||
|
||||
### Deploy Your Application
|
||||
|
||||
Once everything checks out and you're [ready to deploy](https://docs.nanobox.io/workflow/deploy-code/#deploy-to-production), simply run:
|
||||
|
||||
```
|
||||
nanobox deploy
|
||||
```
|
||||
|
||||
Within minutes you're Hugo app will be deployed to your host and humming along smoothly. That's it!
|
|
@ -1,12 +1,12 @@
|
|||
---
|
||||
title: Deployment with Rysnc
|
||||
linktitle: Deployment with Rysnc
|
||||
title: Deployment with Rsync
|
||||
linktitle: Deployment with Rsync
|
||||
description: If you have access to your web host with SSH, you can use a simple rsync one-liner to incrementally deploy your entire Hugo website.
|
||||
date: 2017-02-01
|
||||
publishdate: 2017-02-01
|
||||
lastmod: 2017-02-01
|
||||
categories: [hosting and deployment]
|
||||
#tags: [rysnc,deployment]
|
||||
#tags: [rsync,deployment]
|
||||
authors: [Adrien Poupin]
|
||||
menu:
|
||||
docs:
|
||||
|
|
|
@ -37,13 +37,12 @@ Make sure your `baseURL` key-value in your [site configuration](/getting-started
|
|||
|
||||
[As described in the GitHub Pages documentation][ghpfromdocs], you can deploy from a folder called `docs/` on your master branch. To effectively use this feature with Hugo, you need to change the Hugo publish directory in your [site's][config] `config.toml` and `config.yaml`, respectively:
|
||||
|
||||
```
|
||||
publishDir: docs
|
||||
```
|
||||
|
||||
```
|
||||
publishDir = "docs"
|
||||
```
|
||||
```
|
||||
publishDir: docs
|
||||
```
|
||||
|
||||
After running `hugo`, push your master branch to the remote repository and choose the `docs/` folder as the website source of your repo. Do the following from within your GitHub project:
|
||||
|
||||
|
@ -217,7 +216,7 @@ cd ..
|
|||
```
|
||||
|
||||
|
||||
You can then run `./deploy.sh "Your optional commit message"` to send changes to `<USERNAME>.github.io`. Note that you likely will want to commit changes to your `<YOUR-PROJECDT>` repository as well.
|
||||
You can then run `./deploy.sh "Your optional commit message"` to send changes to `<USERNAME>.github.io`. Note that you likely will want to commit changes to your `<YOUR-PROJECT>` repository as well.
|
||||
|
||||
That's it! Your personal page should be up and running at `https://yourusername.github.io` within a couple minutes.
|
||||
|
||||
|
|
|
@ -38,7 +38,11 @@ cd your-hugo-site
|
|||
In the root directory of your Hugo site, create a `.gitlab-ci.yml` file. The `.gitlab-ci.yml` configures the GitLab CI on how to build your page. Simply add the content below.
|
||||
|
||||
{{< code file="gitlab-ci.yml" >}}
|
||||
image: publysher/hugo
|
||||
image: monachus/hugo
|
||||
|
||||
before_script:
|
||||
- git submodule init
|
||||
- git submodule update --force
|
||||
|
||||
pages:
|
||||
script:
|
||||
|
@ -70,7 +74,7 @@ git push -u origin master
|
|||
|
||||
## Wait for Your Page to Build
|
||||
|
||||
That's it! You can now follow the CI agent building your page at https://gitlab.com/<YourUsername>/<your-hugo-site>/pipelines.
|
||||
That's it! You can now follow the CI agent building your page at `https://gitlab.com/<YourUsername>/<your-hugo-site>/pipelines`.
|
||||
|
||||
After the build has passed, your new website is available at `https://<YourUsername>.gitlab.io/<your-hugo-site>/`.
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ Once selected, you'll be brought to a screen for basic setup. Here you can selec
|
|||
|
||||
Setting the build command to `hugo` will build your site according to the current default Hugo version used by Netlify. You can see the full list of [available Hugo versions in Netlify's Docker file][hugoversions].
|
||||
|
||||
If you want to tell Netlify to build with a specific version, you can append an underscore followed by the version number to the build command:
|
||||
If you want to tell Netlify to build with a specific version (hugo <= 0.20), you can append an underscore followed by the version number to the build command:
|
||||
|
||||
```
|
||||
hugo_0.19
|
||||
|
@ -73,6 +73,22 @@ Your simple configuration should now look similar to the following:
|
|||
|
||||
![Screenshot of 3-step, basic continuous deployment setup with a new Hugo site on Netlify](/images/hosting-and-deployment/hosting-on-netlify/netlify-create-new-site-step-3.jpg)
|
||||
|
||||
For version hugo > 0.20 you have to [specify version hugo for testing and production](https://www.netlify.com/blog/2017/04/11/netlify-plus-hugo-0.20-and-beyond/) in `netlify.toml` file or set `HUGO_VERSION` as a build environment variable in the Netlify console.
|
||||
|
||||
For production:
|
||||
|
||||
```
|
||||
[context.production.environment]
|
||||
HUGO_VERSION = "0.26"
|
||||
```
|
||||
|
||||
For testing:
|
||||
|
||||
```
|
||||
[context.deploy-preview.environment]
|
||||
HUGO_VERSION = "0.26"
|
||||
```
|
||||
|
||||
Selecting "Deploy site" will immediately take you to a terminal for your build:.
|
||||
|
||||
![Animated gif of deploying a site to Netlify, including the terminal read out for the build.](/images/hosting-and-deployment/hosting-on-netlify/netlify-deploying-site.gif)
|
||||
|
|
|
@ -66,7 +66,7 @@ Also note that this is a template for the home page, so the full `Page` with its
|
|||
|
||||
|
||||
## 3. Add Template For the _redirects File
|
||||
Add `layouts/index.redirects`:
|
||||
Add `layouts/index.redir`:
|
||||
```bash
|
||||
# Netlify redirects. See https://www.netlify.com/docs/redirects/
|
||||
{{ range $p := .Site.Pages -}}
|
||||
|
|
|
@ -31,8 +31,8 @@ The [lookup order][lookup] for base templates is as follows:
|
|||
4. `/themes/<THEME>/layouts/<TYPE>/baseof.html`
|
||||
5. `/layouts/section/baseof.html`
|
||||
6. `/themes/<THEME>/layouts/section/baseof.html`
|
||||
7. `/layouts/_default/post-baseof.html`
|
||||
8. `/themes/<THEME>/layouts/_default/post-baseof.html`
|
||||
7. `/layouts/_default/<TYPE>-baseof.html`
|
||||
8. `/themes/<THEME>/layouts/_default/<TYPE>-baseof.html`
|
||||
9. `/layouts/_default/baseof.html`
|
||||
10. `/themes/<THEME>/layouts/_default/baseof.html`
|
||||
|
||||
|
|
|
@ -118,18 +118,14 @@ You can then render your custom Disqus partial template as follows:
|
|||
{{ partial "disqus.html" . }}
|
||||
```
|
||||
|
||||
```
|
||||
_internal/_default/robots.txt
|
||||
_internal/_default/rss.xml
|
||||
_internal/_default/sitemap.xml
|
||||
_internal/_default/sitemapindex.xml
|
||||
## The Internal Templates
|
||||
|
||||
* `_internal/disqus.html`
|
||||
* `_internal/google_news.html`
|
||||
* `_internal/google_analytics.html`
|
||||
* `_internal/google_analytics_async.html`
|
||||
* `_internal/opengraph.html`
|
||||
* `_internal/pagination.html`
|
||||
* `_internal/schema.html`
|
||||
* `_internal/twitter_cards.html`
|
||||
|
||||
_internal/disqus.html
|
||||
_internal/google_news.html
|
||||
_internal/google_analytics.html
|
||||
_internal/google_analytics_async.html
|
||||
_internal/opengraph.html
|
||||
_internal/pagination.html
|
||||
_internal/schema.html
|
||||
_internal/twitter_cards.html
|
||||
```
|
||||
|
|
|
@ -110,7 +110,7 @@ There are more boolean operators than those listed in the Hugo docs in the [Gola
|
|||
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.
|
||||
the `/layouts/` directory within Hugo.
|
||||
|
||||
### Template and Partial Examples
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ You could then include the following as part of your shortcode templating:
|
|||
|
||||
```
|
||||
{{ if .IsNamedParams }}
|
||||
<img src="{{.Get "src" alt="">
|
||||
<img src="{{.Get "src" }}" alt="">
|
||||
{{ else }}
|
||||
<img src="{{.Get 0}}" alt="">
|
||||
{{ end }}.
|
||||
|
@ -345,4 +345,4 @@ More shortcode examples can be found in the [shortcodes directory for spf13.com]
|
|||
[spfscs]: https://github.com/spf13/spf13.com/tree/master/layouts/shortcodes "See more examples of shortcodes by visiting the shortcode directory of the source for spf13.com, the blog of Hugo's creator, Steve Francia."
|
||||
[templates]: /templates/ "The templates section of the Hugo docs."
|
||||
[vimeoexample]: #single-flexible-example-vimeo
|
||||
[youtubeshortcode]: /content-management/shortcodes/#youtube "See how to use Hugo's built-in YouTube shortcode."
|
||||
[youtubeshortcode]: /content-management/shortcodes/#youtube "See how to use Hugo's built-in YouTube shortcode."
|
||||
|
|
|
@ -25,7 +25,7 @@ You can specify a [content's `type`][content type] and `layout` in a single cont
|
|||
Hugo assumes your content section and content type are the same unless you tell Hugo otherwise by providing a `type` directly in the front matter of a content file. This is why #1 and #3 come before #2 and #4, respectively, in the following lookup order. Values in angle brackets (`<>`) are variable.
|
||||
|
||||
1. `/layouts/<TYPE>/<LAYOUT>.html`
|
||||
2. `/layouts/<SECTION>>/<LAYOUT>.html`
|
||||
2. `/layouts/<SECTION>/<LAYOUT>.html`
|
||||
3. `/layouts/<TYPE>/single.html`
|
||||
4. `/layouts/<SECTION>/single.html`
|
||||
5. `/layouts/_default/single.html`
|
||||
|
@ -102,4 +102,4 @@ To easily generate new instances of a content type (e.g., new `.md` files in a s
|
|||
[section]: /content-management/sections/
|
||||
[site variables]: /variables/site/
|
||||
[spf13]: http://spf13.com/
|
||||
[`with`]: /functions/with/
|
||||
[`with`]: /functions/with/
|
||||
|
|
|
@ -143,7 +143,7 @@ Taxonomies can be ordered by either alphabetical key or by the number of content
|
|||
```
|
||||
<ul>
|
||||
{{ $data := .Data }}
|
||||
{{ range $key, $value := .Data.Taxonomy.Alphabetical }}
|
||||
{{ range $key, $value := .Data.Terms.Alphabetical }}
|
||||
<li><a href="{{ $.Site.LanguagePrefix }}/{{ $data.Plural }}/{{ $value.Name | urlize }}"> {{ $value.Name }} </a> {{ $value.Count }} </li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
|
@ -154,7 +154,7 @@ Taxonomies can be ordered by either alphabetical key or by the number of content
|
|||
```
|
||||
<ul>
|
||||
{{ $data := .Data }}
|
||||
{{ range $key, $value := .Data.Taxonomy.ByCount }}
|
||||
{{ range $key, $value := .Data.Terms.ByCount }}
|
||||
<li><a href="{{ $.Site.LanguagePrefix }}/{{ $data.Plural }}/{{ $value.Name | urlize }}"> {{ $value.Name }} </a> {{ $value.Count }} </li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
|
|
|
@ -27,7 +27,7 @@ The following are common use cases for content views:
|
|||
|
||||
## Create a Content View
|
||||
|
||||
To create a new view, create a template in each of your different content type directories with the view name. The following example contains an "li" view and a "summary" view for the `post` and `project` content types. As you can see, these sit next to the [single content view][single] template, `single.html. You can even provide a specific view for a given type and continue to use the `_default/single.html` for the primary view.
|
||||
To create a new view, create a template in each of your different content type directories with the view name. The following example contains an "li" view and a "summary" view for the `post` and `project` content types. As you can see, these sit next to the [single content view][single] template, `single.html`. You can even provide a specific view for a given type and continue to use the `_default/single.html` for the primary view.
|
||||
|
||||
```
|
||||
▾ layouts/
|
||||
|
@ -118,4 +118,4 @@ Continuing on the previous example, we can change our render function to use a s
|
|||
[spfsourcesection]: https://github.com/spf13/spf13.com/blob/master/layouts/_default/section.html
|
||||
[spfsourcesummary]: https://github.com/spf13/spf13.com/blob/master/layouts/_default/summary.html
|
||||
[summaries]: /content-management/summaries/
|
||||
[taxonomylists]: /templates/taxonomy-templates/
|
||||
[taxonomylists]: /templates/taxonomy-templates/
|
||||
|
|
|
@ -79,7 +79,7 @@ Hugo applies the decided theme first and then applies anything that is in the lo
|
|||
|
||||
### Command Line
|
||||
|
||||
There are two different approaches to using a theme with your Hugo website: via the Hugo CLI or as part of your
|
||||
There are two different approaches to using a theme with your Hugo website: via the Hugo CLI or as part of your [site configuration file][config].
|
||||
|
||||
To change a theme via the Hugo CLI, you can pass the `-t` [flag][] when building your site:
|
||||
|
||||
|
@ -109,4 +109,4 @@ The `themename` in the above examples must match the name of the specific theme
|
|||
[flag]: /getting-started/usage/ "See the full list of flags in Hugo's basic usage."
|
||||
[install]: /getting-started/installing/
|
||||
[config]: /getting-started/configuration/ "Learn how to customize your Hugo website configuration file in yaml, toml, or json."
|
||||
[themesrepo]: https://github.com/gohugoio/hugoThemes
|
||||
[themesrepo]: https://github.com/gohugoio/hugoThemes
|
||||
|
|
|
@ -203,7 +203,7 @@ body {
|
|||
Here is the same example but with triple back ticks to denote the fenced code block:
|
||||
|
||||
{{< nohighlight >}}
|
||||
```
|
||||
```css
|
||||
body {
|
||||
font-family: "Noto Sans", sans-serif;
|
||||
}
|
||||
|
@ -234,4 +234,4 @@ Please see individual libraries' documentation for how to implement each of the
|
|||
[Rainbow]: http://craig.is/making/rainbows
|
||||
[Syntax Highlighter]: http://alexgorbatchev.com/SyntaxHighlighter/
|
||||
[Google Prettify]: https://github.com/google/code-prettify
|
||||
[Yandex]: http://yandex.ru/
|
||||
[Yandex]: http://yandex.ru/
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 121 KiB |
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
Binary file not shown.
After Width: | Height: | Size: 66 KiB |
Binary file not shown.
After Width: | Height: | Size: 119 KiB |
Loading…
Reference in a new issue