mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-28 22:50:35 +03:00
all: Unify case of config variable names
All config variables starts with low-case and uses camelCase. If there is abbreviation at the beginning of the name, the whole abbreviation will be written in low-case. If there is abbreviation at the end of the name, the whole abbreviation will be written in upper-case. For example, rssURI.
This commit is contained in:
parent
d9f54a13c1
commit
f21e2f25c9
67 changed files with 469 additions and 469 deletions
|
@ -11,7 +11,7 @@ title: Create a Multilingual Site
|
|||
weight: 10
|
||||
---
|
||||
|
||||
> **Note:** Since v0.17 Hugo has built-in support for the creation of multilingual website. [Read more about it]({{< relref "content/multilingual.md" >}}).
|
||||
> **Note:** Since v0.17 Hugo has built-in support for the creation of multilingual website. [Read more about it]({{< relref "content/multilingual.md" >}}).
|
||||
|
||||
## Introduction
|
||||
|
||||
|
@ -30,10 +30,10 @@ Create your site configs in the root of your repository, for example for an Engl
|
|||
**English Config `config_en.toml`**:
|
||||
|
||||
~~~toml
|
||||
baseurl = "http://acme.com/"
|
||||
baseURL = "http://acme.com/"
|
||||
title = "Acme Inc."
|
||||
contentdir = "content/en"
|
||||
publishdir = "public/en"
|
||||
contentDir = "content/en"
|
||||
publishDir = "public/en"
|
||||
|
||||
[params]
|
||||
locale = "en-US"
|
||||
|
@ -42,10 +42,10 @@ publishdir = "public/en"
|
|||
**Japanese Config `config_ja.toml`**:
|
||||
|
||||
~~~toml
|
||||
baseurl = "http://acme.jp/"
|
||||
baseURL = "http://acme.jp/"
|
||||
title = "有限会社アクミー"
|
||||
contentdir = "content/ja"
|
||||
publishdir = "public/ja"
|
||||
contentDir = "content/ja"
|
||||
publishDir = "public/ja"
|
||||
|
||||
[params]
|
||||
locale = "ja-JP"
|
||||
|
@ -60,16 +60,16 @@ Create `.yaml` (or `.json` or `.toml`) files for each language, under `/data/tra
|
|||
**English Strings `en-US.yaml`**:
|
||||
|
||||
~~~yaml
|
||||
topslogan: Acme Inc.
|
||||
topsubslogan: You'll love us
|
||||
topSlogan: Acme Inc.
|
||||
topSubslogan: You'll love us
|
||||
...
|
||||
~~~
|
||||
|
||||
**Japanese Strings `ja-JP.yaml`**:
|
||||
|
||||
~~~yaml
|
||||
topslogan: 有限会社アクミー
|
||||
topsubslogan: キット勝つぞ
|
||||
topSlogan: 有限会社アクミー
|
||||
topSubslogan: キット勝つぞ
|
||||
...
|
||||
~~~
|
||||
|
||||
|
@ -90,8 +90,8 @@ Now you can reference the strings in your templates. One way is to do it like in
|
|||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1 class="header">{{ ( index $.Site.Data.translations $.Site.Params.locale ).topslogan }}</h1>
|
||||
<h3 class="subheader">{{ ( index $.Site.Data.translations $.Site.Params.locale ).topsubslogan }}</h3>
|
||||
<h1 class="header">{{ ( index $.Site.Data.translations $.Site.Params.locale ).topSlogan }}</h1>
|
||||
<h3 class="subheader">{{ ( index $.Site.Data.translations $.Site.Params.locale ).topSubslogan }}</h3>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -126,7 +126,7 @@ At the time of this writing, Golang does not yet have support for internationali
|
|||
</time>
|
||||
~~~
|
||||
|
||||
This technique extracts the day, month and year by specifying ``.Date.Day``, ``.Date.Month``, and ``.Date.Year``, and uses the month number as a key, when indexing the month name data file.
|
||||
This technique extracts the day, month and year by specifying ``.Date.Day``, ``.Date.Month``, and ``.Date.Year``, and uses the month number as a key, when indexing the month name data file.
|
||||
|
||||
## Create Multilingual Content
|
||||
|
||||
|
|
|
@ -489,7 +489,7 @@ So, let's edit your configuration file to add the theme name:
|
|||
```toml
|
||||
$ vi config.toml
|
||||
theme = "zafta"
|
||||
baseurl = "http://example.org/"
|
||||
baseURL = "http://example.org/"
|
||||
title = "My New Hugo Site"
|
||||
languageCode = "en-us"
|
||||
:wq
|
||||
|
@ -1074,13 +1074,13 @@ templates _much_ easier — so, I'll cover them, now.
|
|||
### Base URL
|
||||
|
||||
While developing and testing your theme, did you notice that the links in the
|
||||
rendered `./public/index.html` file use the full "baseurl" from your
|
||||
rendered `./public/index.html` file use the full "baseURL" from your
|
||||
`./config.toml` file? That's because those files are intended to be deployed
|
||||
to your web server.
|
||||
|
||||
Whenever you test your theme, you start Hugo in web server mode
|
||||
(with `hugo server`) and connect to it with your web browser.
|
||||
That command is smart enough to replace the "baseurl" with
|
||||
That command is smart enough to replace the "baseURL" with
|
||||
`http://localhost:1313` on the fly, so that the links automatically
|
||||
work for you.
|
||||
|
||||
|
|
|
@ -31,22 +31,22 @@ As our goal is to host a website using GitHub Pages, it is natural for us to hos
|
|||
|
||||
### Write a `config.yaml` File
|
||||
|
||||
The very first step in creating a new Hugo site is to [write the config file](/overview/configuration/). This config file is important for at least two reasons: (1) this is where site-wide settings (like the websites `baseurl`) go, and (2) the config file dictates to some extent how Hugo will generate the website. For the example website I created a file `config.yaml` with the following contents
|
||||
The very first step in creating a new Hugo site is to [write the config file](/overview/configuration/). This config file is important for at least two reasons: (1) this is where site-wide settings (like the websites `baseURL`) go, and (2) the config file dictates to some extent how Hugo will generate the website. For the example website I created a file `config.yaml` with the following contents
|
||||
|
||||
---
|
||||
contentdir: "content"
|
||||
layoutdir: "layouts"
|
||||
publishdir: "public"
|
||||
contentDir: "content"
|
||||
layoutDir: "layouts"
|
||||
publishDir: "public"
|
||||
indexes:
|
||||
category: "categories"
|
||||
baseurl: "http://spencerlyon2.github.io/hugo_gh_blog"
|
||||
baseURL: "http://spencerlyon2.github.io/hugo_gh_blog"
|
||||
title: "Hugo Blog Template for GitHub Pages"
|
||||
canonifyurls: true
|
||||
canonifyURLs: true
|
||||
...
|
||||
|
||||
> **Caveat:** Hugo's former default of `canonifyurls: true` has been changed
|
||||
> **Caveat:** Hugo's former default of `canonifyURLs: true` has been changed
|
||||
> to `false` since this tutorial has written. **Please make sure you manually
|
||||
> add `canonifyurls: true` to your `config.yaml`** if you are using Spencer's
|
||||
> add `canonifyURLs: true` to your `config.yaml`** if you are using Spencer's
|
||||
> https://github.com/spencerlyon2/hugo_gh_blog for this tutorial, or you *will*
|
||||
> run into problems such as the CSS files not loading.
|
||||
|
||||
|
@ -55,7 +55,7 @@ The very first step in creating a new Hugo site is to [write the config file](/o
|
|||
|
||||
### Define Structure of Website
|
||||
|
||||
Hugo assumes that you organize the content of your site in a meaningful way and uses the same structure to render the website. Notice that we have the line `contentdir: "content"` in our configuration file. This means that all the actual content of the website should be placed somewhere within a folder named `content`. Hugo treats all directories in `content` as sections. For our example we only need one section: a place to hold our blog posts. So we created two new folders:
|
||||
Hugo assumes that you organize the content of your site in a meaningful way and uses the same structure to render the website. Notice that we have the line `contentDir: "content"` in our configuration file. This means that all the actual content of the website should be placed somewhere within a folder named `content`. Hugo treats all directories in `content` as sections. For our example we only need one section: a place to hold our blog posts. So we created two new folders:
|
||||
|
||||
```
|
||||
▾ <root>/
|
||||
|
@ -115,7 +115,7 @@ The keys set in this section are the mandatory `title` and `date` as well as the
|
|||
|
||||
Once the site is set up and working properly, we need to push it to the correct branch of a GitHub repository so the website can be served through GitHub Pages. There are many ways to do this. Here I will show the workflow I currently use to manage my websites that are hosted through GitHub Pages.
|
||||
|
||||
GitHub Pages will serve up a website for any repository that has a branch called `gh-pages` with a valid `index.html` file at that branch's root. A typical workflow might be to keep the content of a website on the `master` branch of a repository and the generated website on the `gh-pages` branch. This provides nice separation between input and output, but can be very tedious to work with. As a workaround, we will use the `git subtree` family of commands to have the `public` directory (or whatever `publishdir` is set to in your `config.yaml`) mirror the root of the `gh-pages` branch of the repository. This will allow us to do all our work on the `master` branch, run Hugo to have the site output into the `public` directory, and then push that directory directly to the correct place for GitHub Pages to serve our site.
|
||||
GitHub Pages will serve up a website for any repository that has a branch called `gh-pages` with a valid `index.html` file at that branch's root. A typical workflow might be to keep the content of a website on the `master` branch of a repository and the generated website on the `gh-pages` branch. This provides nice separation between input and output, but can be very tedious to work with. As a workaround, we will use the `git subtree` family of commands to have the `public` directory (or whatever `publishDir` is set to in your `config.yaml`) mirror the root of the `gh-pages` branch of the repository. This will allow us to do all our work on the `master` branch, run Hugo to have the site output into the `public` directory, and then push that directory directly to the correct place for GitHub Pages to serve our site.
|
||||
|
||||
To get this properly set up, we will execute a series of commands at the terminal. I will include all of them in one place here for easy copy and paste, and will explain what each line does via comments. Note that this is to be run from the `<root>` directory (wherever the `content` and `layout` folders of your Hugo project live). Also note that you will need to change the commands that have the example repository GitHub address so that they point to your repo.
|
||||
|
||||
|
@ -190,22 +190,22 @@ To build all draft posts *(If you only have drafts, no site will be generated)*
|
|||
**Deploy.sh:**
|
||||
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
echo -e "\033[0;32mDeploying updates to GitHub...\033[0m"
|
||||
|
||||
|
||||
# Build the project.
|
||||
hugo
|
||||
|
||||
|
||||
# Add changes to git.
|
||||
git add -A
|
||||
|
||||
|
||||
# Commit changes.
|
||||
msg="rebuilding site `date`"
|
||||
if [ $# -eq 1 ]
|
||||
then msg="$1"
|
||||
fi
|
||||
git commit -m "$msg"
|
||||
|
||||
|
||||
# Push source and build repos.
|
||||
git push origin master
|
||||
git subtree push --prefix=public git@github.com:spencerlyon2/hugo_gh_blog.git gh-pages
|
||||
|
|
|
@ -46,7 +46,7 @@ The default is for Jekyll to publish to `_site` and for Hugo to publish to `publ
|
|||
|
||||
{
|
||||
..
|
||||
"publishdir": "_site",
|
||||
"publishDir": "_site",
|
||||
..
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue