Hi Hugo member,
I need help and thanks in advance for help.
Requirement:
I have made two branch
- Dev for staging. [config-development.toml]
- Master for Production [config-production.toml]
Problem after deploy
when I deploy with .gitlab-ci.yml Production is working fine but development menu URL showing production URL this is the main issue.
Below is the .gitlab-ci.yml code
variables:
PROD_HUGO_ENV: "production"
PROD_BASE_URL: "https://prodwww.abc.com/"
PROD_DOMAIN: "prodwww.abc.com"
STAGING_HUGO_ENV: "development"
STAGING_BASE_URL: "https://wwwdev.abc.com/"
STAGING_DOMAIN: "wwwdev.abc.com"
.production_variables: &production_variables
HUGO_ENV: ${PROD_HUGO_ENV}
BASE_URL: ${PROD_BASE_URL}
DOMAIN: ${PROD_DOMAIN}
.staging_variables: &staging_variables
HUGO_ENV: ${STAGING_HUGO_ENV}
BASE_URL: ${STAGING_BASE_URL}
DOMAIN: ${STAGING_DOMAIN}
stages:
- build
- deploy
# ====
.build_base: &build_base
stage: build
# All available Hugo versions are listed here: https://gitlab.com/pages/hugo/container_registry
# image: registry.gitlab.com/pages/hugo:0.38.2
image: monachus/hugo
artifacts:
paths:
- public
script:
- export
- hugo --baseURL ${BASE_URL}
build:production:
<<: *build_base
variables:
<<: *production_variables
GIT_SUBMODULE_STRATEGY: recursive
only:
- master
build:staging:
<<: *build_base
variables:
<<: *staging_variables
GIT_SUBMODULE_STRATEGY: recursive
only:
- dev
.deploy_base: &deploy_base
stage: deploy
image: monachus/hugo
script:
- hugo --baseURL ${BASE_URL}
deploy:production:
<<: *deploy_base
variables:
<<: *production_variables
dependencies:
- build:production
only:
- master
deploy:staging:
<<: *deploy_base
variables:
<<: *staging_variables
dependencies:
- build:staging
only:
- dev
and for menu code
{{ range .Site.Menus.main }}
{{ if .HasChildren }}
<li class="menu-item-has-children">
<a href="{{if or ((ne .URL "#") (ne .URL " ")) }} {{ $baseUrl }}{{ .URL }} {{else}} javascript:void(0) {{end}}"> {{ .Name }}</a>
<ul class="sub-menu">
{{ range .Children }}
<li><a href="{{ $baseUrl }}{{ .URL }}">{{ .Name }}</a></li>
{{ end }}
</ul>
</li>
{{ else }}
<li><a href="{{ $baseUrl }}{{ .URL }}"> {{ .Name }}</a> </li>
{{ end }}
{{end}}
{{ if .Site.Params.freeTrial.enable }}
<li><a class="btn-free" href="{{ .Site.Params.freeTrial.buttonUrl }}"> {{ .Site.Params.freeTrial.buttonText }} </a> </li>
{{ end }}
and config.toml
baseurl = "https://wwwdev.abc.com"
contentdir = "content"
layoutdir = "layouts"
publishdir = "public"
env = "development"
languageCode = " "
[[menu.main]]
name = "Home"
url = "/"
weight = 1
identifier = "home"
[[menu.main]]
name = "About us"
url = "/aboutus/"
weight = 2
identifier = "about"
[[menu.main]]
name = "About T Solutions"
url = "/aboutus/"
weight = 22
parent = "about"
[[menu.main]]
name = "Contact us "
url = "/contact/"
weight = 5
identifier = "contact"
Please help