Hi,
I am building a small multiligual website at the moment and I want the same content on a different url.
Like:
examples.com/photos
and
example.com/fotos
Both have the same content. Is there a way not to paste the same content in the markup file?
de/fotos.md
en/photos.md
I hope, that you understand my question.
First, why aren’t you serving these pages under different sites? e.g.,
https://example.org/en/photos/
https://example.org/pt/fotos/
Second, what is the defaultContentLanguage
?
Sorry, I am confused 
That is my hugo.toml:
baseURL = 'https://example.com/'
title = 'Example'
defaultContentLanguage = 'de'
defaultContentLanguageInSubdir = true
[languages]
[languages.de]
languageCode = 'de-DE'
languageName = 'Deutsch 🇩🇪'
contentDir = 'content/de'
weight = 1
[languages.de.menus]
[[languages.de.menus.main]]
name = 'Logos'
pageRef = '/logos'
weight = 10
[[languages.de.menus.main]]
name = 'Fotos'
pageRef = '/fotos'
weight = 20
[[languages.de.menus.main]]
name = 'Sketches'
pageRef = '/sketches'
weight = 30
[[languages.de.menus.main]]
name = 'Kontakt'
pageRef = '/kontakt'
weight = 40
[[languages.de.menus.footer]]
name = 'github'
url = 'https://github.com'
weight = 10
[[languages.de.menus.footer]]
name = 'Stackoverflow'
url = 'https://stackoverflow.com'
weight = 20
[[languages.de.menus.footer]]
name = 'youtube'
url = 'https://youtube.com'
weight = 30
[[languages.de.menus.footer]]
name = 'FreeCodeCamp'
url = 'https://freecodecamp.com'
weight = 40
[languages.en]
languageCode = 'en-US'
languageName = 'English 🇬🇧'
contentDir = 'content/en'
weight = 2
[languages.en.menus]
[[languages.en.menus.main]]
name = 'Logos'
pageRef = '/logos'
weight = 10
[[languages.en.menus.main]]
name = 'Photos'
pageRef = '/fotos'
weight = 20
[[languages.en.menus.main]]
name = 'Sketches'
pageRef = '/sketches'
weight = 30
[[languages.en.menus.main]]
name = 'Contact'
pageRef = '/kontakt'
weight = 40
[[languages.en.menus.footer]]
name = 'github'
url = 'https://github.com'
weight = 10
[[languages.en.menus.footer]]
name = 'Stackoverflow'
url = 'https://stackoverflow.com'
weight = 20
[[languages.en.menus.footer]]
name = 'youtube'
url = 'https://youtube.com'
weight = 30
[[languages.en.menus.footer]]
name = 'FreeCodeCamp'
url = 'https://freecodecamp.com'
weight = 40
My default language is german (de)
OK, so contrary to your initial posting, you are serving these pages like this:
https://example.com/de/fotos/
https://example.com/en/photos/
Is that correct?
yes, that is correct..
Here is a link to my repo for the file structure in the content folder.
I have got also a problem with my navbar(menu). If I switch the language he stays not on the same(active) site.
Will the ‘en’ site always have content for all pages? If yes, we can fill in the missing translations in the de
site with en
content.
Or will it be the other way around? Meaning the de
site will always have content for all pages?
I need to translate the Homepage and the Contact page.. all the other pages have the same content, but should have other urls.
Logos, photos and sketches are the same and homepage and contact not.
That doesn’t answer my question. Are you translating from de to en, or the other way around?
One more question: do the slug and title need to be translated, or can you live with the de
words for these?
At the moment the site is a bit in german and english (denglish). I have to clean up the page.
Would be nice.. if we can translate it.
edit: I Have cleaned up a bit.. should be all german now 
If you want to translate front matter (e.g., title
, slug
, url
), you need to create a stub of the page in the target language, and then retrieve the content from the source site with a shortcode.
content/en/kontakt.md
+++
draft = false
title = 'Contact'
url = 'contact'
+++
{{< content de >}}
layouts/_shortcodes/content.html (layouts/shortcodes/content.html if < v0.146.0)
{{/*
Renders the content of the current page's translation in the specified language.
@param {string} The language key of site from which to retrieve the translation.
@returns {template.HTML}
@example {{< content de >}}
*/}}
{{ with $sourceLanguage := .Get 0 }}
{{ if eq $.Page.Language.Lang $sourceLanguage }}
{{ errorf "The positional parameter passed to the %q shortcode must not be the language key of the current site. See %s" $.Name $.Position }}
{{ else }}
{{ with index (where $.Page.Translations "Language.Lang" $sourceLanguage) 0 }}
{{ .Content }}
{{ else }}
{{ errorf "The %q shortcode was unable to find a %q translation of the %q page. See %s" $.Name $sourceLanguage $.Page.Path $.Position }}
{{ end }}
{{ end }}
{{ else }}
{{ errorf "The %q shortcode requires a positional parameter indicating the source language key. See %s" $.Name $.Position }}
{{ end }}
I’ve revised the shortcode above.
And your language switcher doesn’t work because you’re caching the results of the partial call. Change this:
{{ partialCached "navbar.html" . }}
to this:
{{ partial "navbar.html" . }}
I just noticed a bug in the shortcode (the source language key was hardcoded) and have revised the code above.