diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2022-09-13 20:34:24 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2022-09-13 20:34:24 +0200 |
commit | af23cdca9c9c230ffbffbab96f9600a78c76b75f (patch) | |
tree | 295143582c22fbac26978fc12f027ca497493fb8 /docs/content/en/content-management | |
parent | ab5ce59894520a796ca658ef0385c65c2fa45f99 (diff) | |
parent | 90ad8045056167004d27857a95542936657b8a16 (diff) |
Merge commit '90ad8045056167004d27857a95542936657b8a16'
Diffstat (limited to 'docs/content/en/content-management')
6 files changed, 75 insertions, 18 deletions
diff --git a/docs/content/en/content-management/comments.md b/docs/content/en/content-management/comments.md index ad3a1b55d..5c604fdeb 100644 --- a/docs/content/en/content-management/comments.md +++ b/docs/content/en/content-management/comments.md @@ -4,7 +4,6 @@ linktitle: Comments description: Hugo ships with an internal Disqus template, but this isn't the only commenting system that will work with your new Hugo website. date: 2017-02-01 publishdate: 2017-02-01 -lastmod: 2017-03-09 keywords: [sections,content,organization] categories: [project organization, fundamentals] menu: @@ -60,7 +59,7 @@ These are some alternatives to Disqus: * [Muut](https://muut.com/) * [Remark42](https://remark42.com/) (Open source, Golang, Easy to run docker) * [Staticman](https://staticman.net/) -* [Talkyard](https://www.talkyard.io/blog-comments) (Open source, & serverless hosting) +* [Talkyard](https://blog-comments.talkyard.io/) (Open source, & serverless hosting) * [Utterances](https://utteranc.es/) (Open source, GitHub comments widget built on GitHub issues) [configuration]: /getting-started/configuration/ diff --git a/docs/content/en/content-management/image-processing/index.md b/docs/content/en/content-management/image-processing/index.md index 710c260ca..f2748f5db 100644 --- a/docs/content/en/content-management/image-processing/index.md +++ b/docs/content/en/content-management/image-processing/index.md @@ -28,7 +28,11 @@ content/ └── sunset.jpg <-- page resource ``` -To access an image as a page resource: +## The Image Resource + +The `image` resource gives you access to image-specific attributes like the picture's `Width` and `Height`, as well as powerful processing methods and filters. More on that below. + +Note that the `image` resource can also be retrieved from a [global resource]({{< relref "/hugo-pipes/introduction#from-file-to-resource" >}}) ```go-html-template {{ $image := .Resources.GetMatch "sunset.jpg" }} diff --git a/docs/content/en/content-management/multilingual.md b/docs/content/en/content-management/multilingual.md index d1e7965b2..e2450bb29 100644 --- a/docs/content/en/content-management/multilingual.md +++ b/docs/content/en/content-management/multilingual.md @@ -4,7 +4,6 @@ linktitle: Multilingual description: Hugo supports the creation of websites with multiple languages side by side. date: 2017-01-10 publishdate: 2017-01-10 -lastmod: 2017-01-10 categories: [content management] keywords: [multilingual,i18n, internationalization] menu: @@ -335,13 +334,13 @@ This article has 101 words. ### Query a singular/plural translation -In order to meet singular/plural requirement, you must pass a dictionary (map) with a numeric `.Count` property to the `i18n` function. The below example uses `.ReadingTime` variable which has a built-in `.Count` property. +In other to meet singular/plural requirement, you must pass a dictionary (map) with a numeric `.Count` property to the `i18n` function. The below example uses `.ReadingTime` variable which has a built-in `.Count` property. ```go-html-template {{ i18n "readingTime" .ReadingTime }} ``` -The function will read `.Count` from `.ReadingTime` and evaluate where the number is singular (`one`) or plural (`other`). After that, it will pass to `readingTime` id: +The function will read `.Count` from `.ReadingTime` and evaluate whether the number is singular (`one`) or plural (`other`). After that, it will pass to `readingTime` id in `i18n/en-US.toml` file: {{< code-toggle file="i18n/en-US" >}} [readingTime] @@ -349,7 +348,7 @@ one = "One minute to read" other = "{{.Count}} minutes to read" {{< /code-toggle >}} -Assume `.ReadingTime.Count` in the context has value of 525600. The result will be: +Assuming `.ReadingTime.Count` in the context has value is 525600. The result will be: ```text 525600 minutes to read @@ -361,7 +360,7 @@ If `.ReadingTime.Count` in the context has value is 1. The result is: One minute to read ``` -In case you need to pass custom data: (`(dict "Count" 25)` is minimum requirement) +In case you need to pass a custom data: (`(dict "Count" numeric_value_only)` is minimum requirement) ```go-html-template {{ i18n "readingTime" (dict "Count" 25 "FirstArgument" true "SecondArgument" false "Etc" "so on, so far") }} @@ -507,6 +506,40 @@ The rendering of the main navigation works as usual. `.Site.Menus` will just con </ul> ``` +### Dynamically localizing menus with i18n +While customizing menus per language is useful, your config file can become hard to maintain if you have a lot of languages + +If your menus are the same in all languages (ie. if the only thing that changes is the translated name) you can use the `.Identifier` as a translation key for the menu name: + +{{< code-toggle file="config" >}} +[[menu.main]] +name = "About me" +url = "about" +weight = 1 +identifier = "about" +{{< /code-toggle >}} + +You now need to specify the translations for the menu keys in the i18n files: + +{{< code file="i18n/pt.toml" >}} +[about] +other="Sobre mim" +{{< /code >}} + +And do the appropriate changes in the menu code to use the `i18n` tag with the `.Identifier` as a key. You will also note that here we are using a `default` to fall back to `.Name`, in case the `.Identifier` key is also not present in the language specified in the `defaultContentLanguage` configuration. + +{{< code file="layouts/partials/menu.html" >}} +<ul> + {{- $currentPage := . -}} + {{ range .Site.Menus.main -}} + <li class="{{ if $currentPage.IsMenuCurrent "main" . }}active{{ end }}"> + <a href="{{ .URL | absLangURL }}">{{ i18n .Identifier | default .Name}}</a> + </li> + {{- end }} +</ul> +{{< /code >}} + + ## Missing Translations If a string does not have a translation for the current language, Hugo will use the value from the default language. If no default value is set, an empty string will be shown. @@ -535,6 +568,12 @@ To support Multilingual mode in your themes, some considerations must be taken f If there is more than one language defined, the `LanguagePrefix` variable will equal `/en` (or whatever your `CurrentLanguage` is). If not enabled, it will be an empty string (and is therefore harmless for single-language Hugo websites). + +## Generate multilingual content with `hugo new` +Currently, `hugo new` is not ready to support generating multilingual content. But there is a [proposal topic](https://github.com/gohugoio/hugo/issues/7732) about this in Github issue to discuss how it should work. + + + [abslangurl]: /functions/abslangurl [config]: /getting-started/configuration/ [contenttemplate]: /templates/single-page-templates/ diff --git a/docs/content/en/content-management/page-bundles.md b/docs/content/en/content-management/page-bundles.md index 9561ea2e9..924efccd2 100644 --- a/docs/content/en/content-management/page-bundles.md +++ b/docs/content/en/content-management/page-bundles.md @@ -64,26 +64,27 @@ content/ In the above example `content/` directory, there are four leaf bundles: -about +`about` : This leaf bundle is at the root level (directly under `content` directory) and has only the `index.md`. -my-post +`my-post` : This leaf bundle has the `index.md`, two other content Markdown files and two image files. -image1 -: This image is a page resource of `my-post` +- image1, image2: +These images are page resources of `my-post` and only available in `my-post/index.md` resources. -image2 -: This image is a page resource of `my-post` - and only available in `my-post/index.md` resources. +- content1, content2: +These content files are page resources of `my-post` + and only available in `my-post/index.md` resources. + They will **not** be rendered as individual pages. -my-other-post +`my-other-post` : This leaf bundle has only the `index.md`. -another-leaf-bundle +`another-leaf-bundle` : This leaf bundle is nested under couple of directories. This bundle also has only the `index.md`. diff --git a/docs/content/en/content-management/page-resources.md b/docs/content/en/content-management/page-resources.md index 9f2c0cfab..24b1d03ed 100644 --- a/docs/content/en/content-management/page-resources.md +++ b/docs/content/en/content-management/page-resources.md @@ -131,7 +131,7 @@ name : Sets the value returned in `Name`. {{% warning %}} -The methods `Match` and `GetMatch` use `Name` to match the resources. +The methods `Match`, `Get` and `GetMatch` use `Name` to match the resources. {{%/ warning %}} title diff --git a/docs/content/en/content-management/syntax-highlighting.md b/docs/content/en/content-management/syntax-highlighting.md index 8ff270c54..5195b8211 100644 --- a/docs/content/en/content-management/syntax-highlighting.md +++ b/docs/content/en/content-management/syntax-highlighting.md @@ -80,6 +80,20 @@ func GetTitleFunc(style string) func(s string) string { } {{< / highlight >}} +## Highlight Hugo/GO Template Code + +For highlighting Hugo/GO template code on your page, add `/*` after the opening double curly braces and `*/` before closing curly braces. + +``` go +{{</*/* myshortcode */*/>}} +``` + +Gives this: + +``` go +{{</* myshortcode */>}} +``` + ## Highlight Template Func See [Highlight](/functions/highlight/). |