YourOnly.One's Hugo Test Site

Language selector

EN-PH: <reflangtitle> shortcode test page

Create a link of a ref-erenced file with the actual title pulled automatically; and with multilingual support.

How to use

This is {{< relref >}} expanded.

Syntax: {{< reflangtitle path="" lang="" >}}

  • If lang="" is empty, or not defined, it will search under the same language as the current page.

Shortcode file: /layouts/shortcodes/reflangtitle.html

{{- $path := .Get "path" -}}
{{- $ref := relref . .Params -}}
{{- with .Site.GetPage $path -}}
  {{- range .AllTranslations -}}
    {{ if eq $ref .RelPermalink }}<a href="{{ .RelPermalink }}">{{ .Title }}</a>{{ break }}{{ end }}
  {{- end -}}
{{- end -}}

Examples

with lang

These codes:

- {{< reflangtitle path="reflangtitle-test.md" lang="en-ph" >}}
- {{< reflangtitle path="reflangtitle-test.md" lang="ja" >}}
- {{< reflangtitle path="reflangtitle-test.md" lang="ko" >}}

Will output:

empty or without lang

These codes:

- {{< reflangtitle path="reflangtitle-test.md" >}}
- {{< reflangtitle path="reflangtitle-test.md" lang="" >}}

Will output:

Menu

Language selector