hugo

Fork of github.com/gohugoio/hugo with reverse pagination support

git clone git://git.shimmy1996.com/hugo.git

getenv.md (788B)

    1 ---
    2 title: getenv
    3 description: Returns the value of an environment variable, or an empty string if the environment variable is not set.
    4 date: 2017-02-01
    5 publishdate: 2017-02-01
    6 lastmod: 2021-11-26
    7 categories: [functions]
    8 menu:
    9   docs:
   10     parent: "functions"
   11 keywords: []
   12 signature: ["os.Getenv VARIABLE", "getenv VARIABLE"]
   13 workson: []
   14 hugoversion:
   15 relatedfuncs: []
   16 deprecated: false
   17 aliases: []
   18 ---
   19 Examples:
   20 
   21 ```go-html-template
   22 {{ os.Getenv "HOME" }} --> /home/victor
   23 {{ os.Getenv "USER" }} --> victor
   24 ```
   25 
   26 You can pass values when building your site:
   27 
   28 ```bash
   29 MY_VAR1=foo MY_VAR2=bar hugo
   30 
   31 OR
   32 
   33 export MY_VAR1=foo
   34 export MY_VAR2=bar
   35 hugo
   36 ```
   37 
   38 And then retrieve the values within a template:
   39 
   40 ```go-html-template
   41 {{ os.Getenv "MY_VAR1" }} --> foo
   42 {{ os.Getenv "MY_VAR2" }} --> bar
   43 ```