diff --git a/exampleSite/config/_default/params.toml b/exampleSite/config/_default/params.toml
index 005a479a..d7197587 100644
--- a/exampleSite/config/_default/params.toml
+++ b/exampleSite/config/_default/params.toml
@@ -136,9 +136,8 @@ date_format = "Jan 2, 2006"
# Examples: "3:04 pm" or "15:04"
time_format = "3:04 PM"
-# List delimiter (separates parts of an address)
-# Popular separators are ", " (comma), "
" (new line), " " (space)
-list_delimiter = ", "
+# Address format (choose from the [address_formats] list below or add you own to the list).
+address_format = "en-us"
############################
## Advanced
@@ -167,6 +166,12 @@ link_authors = true
# E.g. To load `/assets/js/custom.js`, set `plugins_js = ["custom"]`.
plugins_js = []
+# Available address formats.
+[address_formats]
+ en-us = {order = ['street', 'city', 'region', 'postcode'], delimiters = [', ', ', ', ' ', '']}
+ en-gb = {order = ['street', 'city', 'region', 'postcode'], delimiters = [', ', ', ', ', ', '']}
+ zh = {order = ['postcode', 'region', 'city', 'street'], delimiters = [' ', ' ', ' ', '']}
+
# Configuration of publication pages.
[publications]
# Date format (refer to https://sourcethemes.com/academic/docs/customization/#date-format )
diff --git a/layouts/partials/functions/get_address.html b/layouts/partials/functions/get_address.html
new file mode 100644
index 00000000..02eec101
--- /dev/null
+++ b/layouts/partials/functions/get_address.html
@@ -0,0 +1,21 @@
+{{/* Function to return a formatted address given a semantic address. */}}
+
+{{/* Check for valid site config. */}}
+{{ if not site.Params.address_format }}{{errorf "Address format missing from `params.toml`!"}}{{end}}
+{{ if not site.Params.address_formats }}{{errorf "Address formats missing from `params.toml`!"}}{{end}}
+
+{{ $page := . }}
+{{ $address := .address }}
+{{ $format_name := $page.Params.address_format | default site.Params.address_format | default "en-us" }}
+{{ $format := index site.Params.address_formats $format_name }}
+{{ $address_display := slice }}
+
+{{ range $k, $v := $format.order }}
+ {{ if eq $v "street" | and $address.street }}{{$address_display = $address_display | append $address.street | append (index $format.delimiters $k | default "") }}{{end}}
+ {{ if eq $v "city" | and $address.city }}{{$address_display = $address_display | append $address.city | append (index $format.delimiters $k | default "") }}{{end}}
+ {{ if eq $v "region" | and $address.region }}{{$address_display = $address_display | append $address.region | append (index $format.delimiters $k | default "") }}{{end}}
+ {{ if eq $v "postcode" | and $address.postcode }}{{$address_display = $address_display | append $address.postcode | append (index $format.delimiters $k | default "") }}{{end}}
+ {{ if eq $v "country" | and $address.country }}{{$address_display = $address_display | append $address.country | append (index $format.delimiters $k | default "") }}{{end}}
+{{end}}
+
+{{ return (delimit $address_display "") }}
diff --git a/layouts/partials/widgets/contact.html b/layouts/partials/widgets/contact.html
index 11be65fb..ddc46091 100644
--- a/layouts/partials/widgets/contact.html
+++ b/layouts/partials/widgets/contact.html
@@ -65,16 +65,10 @@
{{ $addr_formatted := "" }}{{/* Scoping for maps. */}}
{{ if $data.address.street | or $data.address.city | or $data.address.region | or $data.address.postcode | or $data.address.country }}
- {{ $addr := slice }}
- {{with $data.address.street}}{{$addr = $addr | append .}}{{end}}
- {{with $data.address.city}}{{$addr = $addr | append .}}{{end}}
- {{with $data.address.region}}{{$addr = $addr | append .}}{{end}}
- {{with $data.address.postcode}}{{$addr = $addr | append .}}{{end}}
- {{with $data.address.country}}{{$addr = $addr | append .}}{{end}}
- {{ $addr_formatted = delimit $addr (site.Params.list_delimiter | default ", ") }}
+ {{ $addr_formatted = partial "functions/get_address" (dict "root" . "address" $data.address) }}