Update URL docs for relative URLs etc

This commit is contained in:
Bjørn Erik Pedersen 2019-04-18 09:48:39 +02:00
parent bd58dd877a
commit 9a7e192314
No known key found for this signature in database
GPG Key ID: 330E6E2BD4859D8F

View File

@ -84,7 +84,6 @@ The following is a list of values that can be used in a `permalink` definition i
Aliases can be used to create redirects to your page from other URLs. Aliases can be used to create redirects to your page from other URLs.
Aliases comes in two forms: Aliases comes in two forms:
1. Starting with a `/` meaning they are relative to the `BaseURL`, e.g. `/posts/my-blogpost/` 1. Starting with a `/` meaning they are relative to the `BaseURL`, e.g. `/posts/my-blogpost/`
@ -130,6 +129,8 @@ aliases:
--- ---
``` ```
From Hugo 0.55 you can also have page-relative aliases, so ` /es/posts/my-original-post/` can be simplified to the more portable `my-original-post/`
### How Hugo Aliases Work ### How Hugo Aliases Work
When aliases are specified, Hugo creates a directory to match the alias entry. Inside the directory, Hugo creates an `.html` file specifying the canonical URL for the page and the new redirect target. When aliases are specified, Hugo creates a directory to match the alias entry. Inside the directory, Hugo creates an `.html` file specifying the canonical URL for the page and the new redirect target.
@ -257,12 +258,29 @@ Or, if you are on Windows and do not have `grep` installed:
hugo config | FINDSTR /I canon hugo config | FINDSTR /I canon
``` ```
## Override URLs with Front Matter ## Set URL in Front Matter
In addition to specifying permalink values in your site configuration for different content sections, Hugo provides even more granular control for individual pieces of content. In addition to specifying permalink values in your site configuration for different content sections, Hugo provides even more granular control for individual pieces of content.
Both `slug` and `url` can be defined in individual front matter. For more information on content destinations at build time, see [Content Organization][contentorg]. Both `slug` and `url` can be defined in individual front matter. For more information on content destinations at build time, see [Content Organization][contentorg].
From Hugo 0.55, you can use URLs relative to the current site context (the language), which makes it simpler to maintain. For a Japanese translation, both of the following examples would get the same URL:
```markdown
---
title: "Custom URL!"
url: "/jp/custom/foo"
---
```
```markdown
---
title: "Custom URL!"
url: "custom/foo"
---
```
## Relative URLs ## Relative URLs
By default, all relative URLs are left unchanged by Hugo, which can be problematic when you want to make your site browsable from a local file system. By default, all relative URLs are left unchanged by Hugo, which can be problematic when you want to make your site browsable from a local file system.