diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5cbc681..2600732 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,7 +6,7 @@ variables: # build.js authenticates to the GitHub API with this token to avoid rate limits. # The multiplatform buildx job reads EXTRA_DOCKER_ARGS (not the legacy inline # --build-arg), so pass the token through there. - EXTRA_DOCKER_ARGS: "--build-arg GITHUB_USERNAME_TOKEN" + EXTRA_DOCKER_ARGS: "--build-arg GITHUB_USERNAME_TOKEN --build-arg SEARCH_ENGINES_DISABLED=false" # do not disable search engines by default DOCKER_HOST: value: 'tcp://docker:2376' description: "Required to run dind inside k8s runners with TLS" @@ -39,6 +39,9 @@ build:docker: build:docker-multiplatform: rules: + - if: '$CI_COMMIT_BRANCH == "master"' + variables: + EXTRA_DOCKER_ARGS: "--build-arg GITHUB_USERNAME_TOKEN --build-arg SEARCH_ENGINES_DISABLED=true" # disable if the branch is master (staging) - if: '$CI_COMMIT_BRANCH =~ /^(master|production)$/' publish:image: diff --git a/Dockerfile b/Dockerfile index e0e3d5b..29b74c9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,12 @@ FROM node:26-alpine AS build ARG GITHUB_USERNAME_TOKEN + +ARG SEARCH_ENGINES_DISABLED +ENV HUGO_PARAMS_SEARCHENGINES_DISABLED=$SEARCH_ENGINES_DISABLED + WORKDIR /build-website -ADD https://github.com/gohugoio/hugo/releases/download/v0.166.0/hugo_0.166.0_Linux-64bit.tar.gz hugo.tar.gz -RUN echo "45228f5a52eb118b0ca168068f01d7df0447314a24056f1d29667ed9fc368308 hugo.tar.gz" | sha256sum -c +ADD https://github.com/gohugoio/hugo/releases/download/v0.167.0/hugo_0.167.0_Linux-64bit.tar.gz hugo.tar.gz +RUN echo "4d84519b9f619e6d4c3fb45a50157abeabeb724f859c60605f44c23def6e1169 hugo.tar.gz" | sha256sum -c RUN tar -zxvf hugo.tar.gz COPY package-lock.json package.json ./ RUN npm ci diff --git a/config.toml b/config.toml index 0c36b34..444f7ba 100644 --- a/config.toml +++ b/config.toml @@ -6,6 +6,12 @@ theme = "cfbs-theme" enableRobotsTXT = true syntaxCSS = true +# this parameter is set by Hugo from HUGO_PARAMS_SEARCHENGINES_DISABLED environment variable +# that we define on the build stage +# it is false by defaut to avoid a case when it was accedntly not defined +[params.searchengines] +disabled = false + # Number of posts per page [pagination] pagerSize = 10 diff --git a/themes/cfbs-theme/layouts/robots.txt b/themes/cfbs-theme/layouts/robots.txt new file mode 100644 index 0000000..7a5d82b --- /dev/null +++ b/themes/cfbs-theme/layouts/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +{{ if .Site.Params.searchengines.disabled }}Disallow: /{{ end }}