Age | Commit message (Collapse) | Author |
|
The language switcher didn't work with more than 2 languages, but this
is a fix. It lists all translations first, then sorts them by weight.
Got ideas from this thread: https://discourse.gohugo.io/t/language-switcher-in-menu/11570/7
|
|
There is a link to the home page in the header, which is generated by
the .Site.BaseURL variable in header.html layout. This link refers to
the home page of the defaultContentLanguage everywhere, also on
translated pages.
Expected behavior: link to to the translated home page
There can only be one BaseURL, since it is a global variable that can't
be overwritten by language parameters.
According to this:
https://jibecfed.fedorapeople.org/blog-hugo/en/2018/11/building-a-multilingual-static-website-with-hugo/
a fix should be using {{.Site.BaseURL | relLangURL }}
but it is not working. I replaced the .Site.BaseURL with "/" (which is
what is currently the baseURL), and it works.
the relLangURL function seems to be buggy in Hugo: https://github.com/gohugoio/hugo/pull/5369
But I haven't found a solution yet.
|
|
This adds an additional CSS class to the header if Site.Params.Language
Switcher.show is set to `true`, changing the CSS grid so it integrates
the language switcher.
|
|
And adjust CSS accordingly
|
|
This shows language switcher in header only if params.languageSwitcher.
show in config.toml is set to `true`.
|
|
The language switcher is a navigation menu which shows all available
translations of a given page, only if there are any.
See https://regisphilibert.com/blog/2018/08/hugo-multilingual-part-1-managing-content-translation/#using-linked-translations-in-your-template
|
|
|
|
include og:locale in open graph meta data
The open graph protocol enables web pages to show up as rich objects in
a social graph, see: https://ogp.me/
Which basically means that when someone shares a link of a webpage on
Facebook, it will look like a page on Facebook instead of an external
web page.
Hugo has an internal template for Open Graph meta data:
https://gohugo.io/templates/internal/#open-graph
It is used in Terrassa theme.
However, I wanted to include the optional meta tag og:locale, to signal
to social media platforms which language the page is in.
Hugo's template includes og:locale, but it is set using page parameters,
not site parameters, see code here on line 30:
https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/opengraph.html
This doesn't make sense to me, because then we'd have to define the
locale parameter in the front matter of every single page for it to render. We could do that automatically by adding a line in `archetypes` default, which defines the default parameters that are added to each page, but still this means an additional line in every page that we create.
So I decided to manually add og:locale meta tag in head.html.
I can come back to this later, if I ever figure out why Hugo does it
that way, and change it but this works for now.
|
|
This adds hreflang-tags to <head>.
See https://moz.com/learn/seo/hreflang-tag
Hugo stores translations in .Translations and links translations,
if the content directory is set up properly.
See https://regisphilibert.com/blog/2018/08/hugo-multilingual-part-1-managing-content-translation/
This code checks if the page is translated, then creates hreflang tags
for all translated versions including the current page. This is
important because hreflang-tags need to be self-referencing (search
engines need to know all available versions).
|
|
|
|
Building sites… WARN 2019/06/01 12:28:30 Page's .Hugo is deprecated and will be removed in a future release. Use the global hugo function.
Fixed by updating deprecated ".Hugo" to "hugo" in layouts/partials/head.html
|
|
|
|
|
|
|
|
|
|
I found the text a little too close to the footer in that case
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|