Output .Permalink with current hostname of page regardless of baseurl

How would I go about getting {{ .Permalink }} to output the hostname of the current page regardless of what is set in baseurl

My situation is that we have functionality that requires the full url and we have three environments that we need to test on.

dev.domain.com
staging.domain.com
domain.com

Setting baseurl as / only outputs the filename outside of localhost

I guess I can retrieve current hostname with go or javascript but is there a hugo way of achieving this?

Thanks

I’m not sure why you cannot set baseURL as dev.domain.com etc.

Hugo is a STATIC site generator, so we cannot pick up any info from a web server.

Because if I set BaseURL to dev.domain.com then on staging.domain.com all permalinks will point to that server.

I could look into loading different config files per env but the problem here is that we don’t know what the production url is.

I could retrieve hostname with javascript and inject but this is for facebook sharing and that info needs to be on page load. looks like i will have to get my hands dirty with Go. Thanks

hugo --baseURL=http://dev.domain.com… you can even set it as an OS env var (HUGO_BASEURL) …

This is really what you really want.