HUGO

Hugo server - Know which port correspond to each language

I have a multilanguage site. When running it locally, it attributes each language its separate port (which is fine). Yet, I have a hard time knowing which port corresponds to which language. When running hugo server -D, this is what I got.
Is there a command parameter to show the language corresponding to each port? Otherwise, that migth be a nice-to-add feature.

Alternatively, is there a way to ask Hugo to only render one language in particular? So that I can get only the one I am working on.

Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Environment: "development"
Web Server is available at http://localhost:1314/ (bind address 127.0.0.1)
Environment: "development"
Web Server is available at http://localhost:1315/ (bind address 127.0.0.1)
Environment: "development"
Web Server is available at http://localhost:1316/ (bind address 127.0.0.1)
Environment: "development"
Web Server is available at http://localhost:1317/ (bind address 127.0.0.1)
Environment: "development"
Web Server is available at http://localhost:1318/ (bind address 127.0.0.1)
Environment: "development"
Web Server is available at http://localhost:1319/ (bind address 127.0.0.1)

You can disable languages: Multilingual Mode | Hugo

From the docs:

Note that you cannot disable the default content language.

So you may still have :1313 and a :1314 if you want to work with a language that is not the default.


You could do something like this from one of your layouts:

{{ if site.Home.IsTranslated }}
  {{ range site.Home.Translations }}
    {{ warnf (print .Language.LanguageName " : " .Permalink) }}
  {{ end }}
{{ end }}

Which would result in something like:

Start building sites … 
WARN 2021/04/14 13:37:22 Latin : http://localhost:1314/
WARN 2021/04/14 13:37:23 English : http://localhost:1313/

                   | EN | LA  
-------------------+----+-----

...

Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Environment: "development"
Web Server is available at http://localhost:1314/ (bind address 127.0.0.1)
Press Ctrl+C to stop
2 Likes

Thanks a lot!
Using your idea in the base template, I had the range duplicated for each language, so I did that

{{ if site.Home.IsTranslated }}
    {{ if .IsHome }}
        {{ warnf (print .Language " : " .Permalink) }}
    {{ end }}
{{ end }}

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.