Print .Site.BaseURL (production)

Hello,

How can I print the {{ .SiteBaseURL }}? Not the development variable http://localhost:1313, but the production one.

I have:

baseURL = "https://www.mysite.com/"

And, for a plugin I’m working on, I need to print https://www.mysite.com/, not the localhost url.

(I will be releasing this plugin for others to use, so I can’t use any shortcuts like “starting the server with --dothis or anything like that”.)

Is there currently a way to print it?

No. The value of .Site.BaseURL is dynamic depending on environment (server vs. production) and the --baseURL command line argument.

You could use readFile + transformUnmarshal:

{{ $config := readFile "config.toml" | transform.Unmarshal }}
{{ $config.baseURL }}

Mmm doesn’t appear to work. Gives me some cryptic error.

Works for me. :woman_shrugging: Can’t help if I can’t replicate.