I’ve a website to generate content according to the different type of users as below. I simply have an environment variable in my dockerfile as below and I run hugo according to the user type.
But what confuse me we have stage and production environment, thus ı need to update the baseUrl in config.yaml for all of them. What is the best approach of doing this ?
I might update it via sed
but never tried cause I believe there might be a good way of doing this. Any help will be appreciated.
baseURL = “https://int-foo-example.com/” → stage
baseURL = “https://foo-example.com/” → production
RUN hugo -e ${AUDIENCE} --minify
Here is the tree structure.
├── config/
│ ├── _default
│ │ └── config.yaml
│ ├── dealers
│ ├── config.yaml
│ │ └── params.yaml
│ └── employees
│ ├── config.yaml
│ └── params.yaml
├── content
You can set the baseURL
and the config
directly from the CLI according to the environment.
See hugo
CLI, also if you are using a CI/CD service like Netlify you can Configure with Enviroment Variables
Hi,
I need to manage all this in dockerfile… Cant I do something as below… I tried but it did not work…
I tried to run below command and received below error.
Step 15/23 : RUN hugo -e ${AUDIENCE} --config ./config/config-${ENVIRONMENT}.toml --minify
Start building sites …
ERROR 2021/02/08 06:40:41 [en] REF_NOT_FOUND: Ref "faq": "/src/hugo/content/en/docs/basic-use-cases/apiusage/_index.md:67:66": page reference "/en/docs/basic-use-cases/apiusage/faq" is ambiguous
Total in 2953 ms
e[91mError: Error building site: "/src/hugo/content/en/docs/introduction/demo/_index.md:23:1": failed to render shortcode "attachments": failed to process shortcode: "/src/hugo/layouts/shortcodes/attachments.html:9:11": execute of template failed: template: shortcodes/attachments.html:9:11: executing "shortcodes/attachments.html" at <readDir (printf "./content/en/%s%s" .Page.File.Dir ($.Scratch.Get "filesName"))>: error calling readDir: failed to read directory "./content/en/en/docs/introduction/demo/files": open /src/hugo/content/en/en/docs/introduction/demo/files: no such file or directory
e[0mThe command '/bin/sh -c hugo -e ${AUDIENCE} --config ./config/config-${ENVIRONMENT}.toml --minify' returned a non-zero code: 255
├── config/
│ ├── _default
│ │ └── **config-stage.yaml**
│ │ └── **config-prod.yaml**
│ ├── dealers
│ │ └── **config-stage.yaml**
│ │ └── **config-prod.yaml**
│ │ └── params.yaml
│ └── employees
│ │ └── **config-stage.yaml**
│ │ └── **config-prod.yaml**
│ └── params.yaml
├── content
I haven’t seen this error in a long time.
How are you calling .GetPage
in your template?