Open agoodfellow123 opened 1 year ago
Reference: https://discourse.gohugo.io/t/40965
config.toml
[languages.en]
weight = 1
languageCode = 'en-US'
languageName = 'English'
[languages.de]
weight = 2
languageCode = 'de-DE'
languageName = 'Deutsch'
Override the header template
mkdir -p layouts/partials
cp themes/hugo.386/layouts/partials/header.html layouts/partials/
Then modify layouts/partials/header.html
diff --git a/layouts/partials/header.html b/layouts/partials/header.html
index 7fe2281..e3f2bf3 100644
--- a/layouts/partials/header.html
+++ b/layouts/partials/header.html
@@ -33,7 +33,12 @@
{{ end }}
{{ end }}
</ul>
+ <ul class="nav" style="float: right">
+ {{ range .AllTranslations }}
+ <li><a href="{{ .RelPermalink }}">{{ .Language.LanguageName }}</a></li>
+ {{ end }}
+ </ul>
</div>
</div>
</div>
The language switcher is available in both the collapsed and expanded menu. Perhaps @maxlefou can suggest a better way to do this.
this version isn't really supported anymore since another revamp is in the way for the main reason that it uses Bootstrap in version 2. but feel free to make pull requests
It works! Thank you. However, I couldn't manage to do the margin equal to "My New Hugo Site" here is what I tried:
<ul class="nav" style="float: right" margin-right="-10px">
When I inspect the element it says the margin value was read from Bootstrap.css How do I overwrite that?
Edit: Nevermind I solved it like this: <ul class="nav" style="float: right; margin-right: -10px;">
Also two new problems occured, I want language buttons to send you to the homepage of the language so this is what I done:
{{ if .Language.LanguageName .Language.LanguageName.English}}
<li><a href="/">{{ .Language.LanguageName }}</a></li>
{{ else }}
<li><a href="/tr">{{ .Language.LanguageName }}</a></li>
{{ end }}
Sadly that doesn't seem like how that works.
Also on the mobile site this happens:
Hello. I am not a web developer and this is my first time getting exposed to CSS and HTML but I tried to change some things on the theme. I semi successfully removed the aspect ratio limit (it still appears when I zoom in but looks fine when zoomed out):
However, one thing that really bothered me was the inability to add menus to the right side of the header instead of the default left side, here is what I tried so far:
header.html