How to check if the site is on localhost?

use separated config for release

// config-release.toml
BaseURL  = "http://mydomain.com/"
PublishDir = "/var/www/mysite"
[params]
   isRelease = true

// config.toml
BaseURL   = http://localhost:1313/

// layout
{{ if .Site.Params.isRelease }}
  some release code, like Google Analytics
{{ else }}
  some dev code, like logging
{{ end }}

use next commands

// to release
hugo --config ./config-release.toml

// to dev
hugo server