Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-03-31 13:08:15 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-04-02 11:33:15 +0300
commit5185fb065b0f8a4142c29ee3e3cd917e917280a4 (patch)
treec4aad127193563eabac21e76cfc4e8e19408b155 /resources/page
parent92baa14fd3f45c0917c5988235cd1a0f8692f171 (diff)
hugolib: Allow relative URLs in front matter
Before this commit you would have to do this in multilingual setups: ``` --- title: "Custom!" url: "/jp/custom/foo" --- ``` This commit allows for relative URLs, e.g: ``` --- title: "Custom!" url: "custom/foo" --- ``` Which is obviously easier and more portable. The meaning of relative may change to include more in the future (e.g. role based access). Fixes #5704
Diffstat (limited to 'resources/page')
-rw-r--r--resources/page/page_paths.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/resources/page/page_paths.go b/resources/page/page_paths.go
index 160c225b1..89616d421 100644
--- a/resources/page/page_paths.go
+++ b/resources/page/page_paths.go
@@ -124,6 +124,11 @@ func CreateTargetPaths(d TargetPathDescriptor) (tp TargetPaths) {
}
+ if d.URL != "" && !strings.HasPrefix(d.URL, "/") {
+ // Treat this as a context relative URL
+ d.ForcePrefix = true
+ }
+
pagePath := slash
var (