Hello
The netlify domain is:
and my own being:
On the first domain, when I click on a link it takes me the correct place but on the other domain. I’d like it to stay on the same domain. Is this possible?
I am asking because when I work on other projects, and use the first domain to show my clients before using their domain, they can take a look at the site, where the links work
Header:
<ul class="header-nav">
{{ $currentPage := . }}
{{ range .Site.Menus.main -}}
<li class='header-nav__list-item {{ if $currentPage.IsMenuCurrent "main" . }} active {{ end }}'>
<a class="header-nav__list-link" href="{{ .URL | absLangURL }}">{{ .Name }}</a>
</li>
{{ end }}
</ul>
Config file:
[languages.en]
contentDir = 'content/english'
description = 'Kaliriu in English'
languageCode = 'en-US'
languageName = 'English'
weight = 1
[[languages.en.menu.main]]
identifier = 'home'
name = 'Home'
pageRef = '/'
weight = 1
[[languages.en.menu.main]]
identifier = 'projects'
name = 'Projects'
url = '/projects'
weight = 2
[[languages.en.menu.main]]
identifier = 'blog'
name = 'Blog'
url = '/blog'
weight = 3
[[languages.en.menu.main]]
identifier = 'contact'
name = 'Contact'
url = '/contact'
weight = 4
[languages.es]
contentDir = 'content/spanish'
description = 'Kaliriu en Español'
languageCode = 'es-ES'
languageName = 'Español'
weight = 2
[[languages.es.menu.main]]
identifier = 'inicio'
name = 'Inicio'
pageRef = '/'
weight = 1
[[languages.es.menu.main]]
identifier = 'proyectos'
name = 'Proyectos'
url = '/es/projects'
weight = 1
[[languages.es.menu.main]]
identifier = 'blog'
name = 'Blog'
url = '/es/blog'
weight = 2
[[languages.es.menu.main]]
identifier = 'contacto'
name = 'Contacto'
url = '/es/contact'
weight = 3
@Paloma_M
You and I have discussed menu definition before:
https://discourse.gohugo.io/t/38727/2
- You can omit the
identifier
property unless two or more entries in a given language have the same name
property.
- Use the
pageRef
property for internal links, and use the url
property for external links. If you don’t do this, you will run into this issue.
- Omit the language prefix (example:
/es
) when specifying the pageRef
property. You’ve defined the menu entries per language, so Hugo knows what to do.
With these changes, your site configuration should look like this:
config.toml
[languages.en]
contentDir = 'content/english'
description = 'Kaliriu in English'
languageCode = 'en-US'
languageName = 'English'
weight = 1
[[languages.en.menu.main]]
name = 'Home'
pageRef = '/'
weight = 1
[[languages.en.menu.main]]
name = 'Projects'
pageRef = '/projects'
weight = 2
[[languages.en.menu.main]]
name = 'Blog'
pageRef = '/blog'
weight = 3
[[languages.en.menu.main]]
name = 'Contact'
pageRef = '/contact'
weight = 4
[languages.es]
contentDir = 'content/spanish'
description = 'Kaliriu en Español'
languageCode = 'es-ES'
languageName = 'Español'
weight = 2
[[languages.es.menu.main]]
name = 'Inicio'
pageRef = '/'
weight = 1
[[languages.es.menu.main]]
name = 'Proyectos'
pageRef = '/projects'
weight = 2
[[languages.es.menu.main]]
name = 'Blog'
pageRef = '/blog'
weight = 3
[[languages.es.menu.main]]
name = 'Contacto'
pageRef = '/contact'
weight = 4
Finally, to allow your site to be served correctly from both kaliriu.netlify.app
and kaliriu.com
, do not pass the menu entry URL
through absLangURL
. Change this:
<a class="header-nav__list-link" href="{{ .URL | absLangURL }}">{{ .Name }}</a>
To this:
<a class="header-nav__list-link" href="{{ .URL }}">{{ .Name }}</a>
Thank you
But it is also giving me issues on:
pascualdesigner.netlify.app
When I click on a link, it adds the whole route of the link
Header:
{{- $currentPage := . -}}
{{ range .Site.Menus.main -}}
<li class='header-nav__list-item {{ if $currentPage.IsMenuCurrent "main" . }} active {{ end }}'>
<a class="header-nav__list-link" href="{{ .URL }}">{{ .Name }}</a>
</li>
{{- end }}
Config
`
[languages.en]
contentDir = 'content/english'
description = 'Pascual in English'
languageCode = 'en-US'
languageName = 'English'
weight = 1
[[languages.en.menu.main]]
name = 'Projects'
pageRef = '/projects'
weight = 1
[[languages.en.menu.main]]
name = 'Services'
pageRef = '/services'
weight = 2
[[languages.en.menu.main]]
name = 'Products'
pageRef = '/products'
weight = 3
[[languages.en.menu.main]]
name = 'About us'
pageRef = '/about'
weight = 4
[[languages.en.menu.main]]
name = 'Blog'
pageRef = '/blog'
weight = 5
[[languages.en.menu.main]]
name = 'Contact'
pageRef = '/contact'
weight = 6
[languages.es]
contentDir = 'content/spanish'
description = 'Pascual en Español'
languageCode = 'es-ES'
languageName = 'Español'
weight = 2
[[languages.es.menu.main]]
name = 'Proyectos'
pageRef = '/projects'
weight = 1
[[languages.es.menu.main]]
name = 'Servicios'
pageRef = '/services'
weight = 2
[[languages.es.menu.main]]
name = 'Productos'
pageRef = '/products'
weight = 3
[[languages.es.menu.main]]
name = 'Sobre nosotros'
pageRef = '/about'
weight = 4
[[languages.es.menu.main]]
name = 'Blog'
pageRef = '/blog'
weight = 5
[[languages.es.menu.main]]
name = 'Contacto'
pageRef = '/contact'
weight = 6
`
I am unable to reproduce the problem. Try it:
git clone --single-branch -b hugo-forum-topic-40357 https://github.com/jmooring/hugo-testing hugo-forum-topic-40357
cd hugo-forum-topic-40357
hugo server
If you need additional assistance, please share a link to the public repository for your project.
I suspect that the baseURL
in your site configuration is missing the protocol.
Wrong:
baseURL = 'pascualdesigner.netlify.app'
Right:
baseURL = 'https://pascualdesigner.netlify.app/'