docs: some more on absURL, relURL
authorbep <bjorn.erik.pedersen@gmail.com>
Fri, 22 May 2015 21:43:12 +0000 (23:43 +0200)
committerbep <bjorn.erik.pedersen@gmail.com>
Fri, 22 May 2015 21:43:02 +0000 (23:43 +0200)
docs/content/templates/functions.md

index 6c267f0f594df2e9187fad6486d3e30afa7c6b50..c949fa987ef052b5191f15806dd8e139f45ad322 100644 (file)
@@ -440,8 +440,26 @@ Both `absURL` and `relURL` considers the configured value of `baseURL`, so given
 
 * `{{ "mystyle.css" | absURL }}` → "http://mysite.com/hugo/mystyle.css"
 * `{{ "mystyle.css" | relURL }}` → "/hugo/mystyle.css"
+* `{{ "http://gohugo.io/" | relURL }}` →  "http://gohugo.io/"
+* `{{ "http://gohugo.io/" | absURL }}` →  "http://gohugo.io/"
 
-**Note:** If `canonifyUrls` is enabled, the last example above will be "/mystyle.css". These functions are smart about missing slashes, but will not add one to the end if not present.
+The last two examples may look funky, but is useful if you, say, have a list of images, some of them hosted externally, some locally:
+
+```
+<script type="application/ld+json">
+{
+    "@context" : "http://schema.org",
+    "@type" : "BlogPosting",
+    "image" : {{ apply .Params.images "absURL" "." }}
+}
+</script>
+```
+
+The above also exploits the fact that the Go template parser JSON-encodes objects inside `script` tags.
+
+
+
+**Note:** These functions are smart about missing slashes, but will not add one to the end if not present.
 
 
 ### ref, relref