Using environment variables in code may not an advisable approach for those building following Twelve-Factor App principals, which state about config:
Apps sometimes store config as constants in the code. This is a violation of twelve-factor, which requires strict separation of config from code. Config varies substantially across deploys, code does not.
As an alternative consider instead passing config to app via hugo bin flags at build time, a common approach seen in the PHP and Ruby web development communities.