CICD Pipeline Artifact Not Generating Hugo Shortcode Content

,

I have a public repo Mark McFadden / todaysprayer · GitLab. The site is a static site generated with Hugo. I can successfully generate the content locally and view it. However, in the CICD Pipeline, which runs with no errors, the artifact is not showing content from the index.md markdown file’s shortcodes. In essence, what is displayed is a page with no content, other than the default theme HTML. What am I not doing correctly?

Here is my .gitlab-ci.yml content:

image: registry.gitlab.com/pages/hugo/hugo_extended:latest

variables:
  GIT_SUBMODULE_STRATEGY: recursive

pages:
  script:
  - hugo
  artifacts:
    paths:
    - public
  rules:
  - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

Here is my config.toml content:

baseURL = 'https://msquaredweb.gitlab.io/todaysprayer/'
languageCode = 'en-us'
title = "Today's Prayer Site"
theme = "jane"

[[menu.main]]
  name = "Contact Mark"
  weight = 10
  identifier = "contact"
  url = "mailto:m2web@yahoo.com?subject=Contact%20from%20Today's%20Prayer%20Site"

[[menu.main]]
  name = "Make a Suggestion"
  weight = 20
  identifier = "site suggestions"
  url = "mailto:m2web@yahoo.com?subject=Today's%20Prayer%20Site%20Suggestions"

[Params]
  customCSS = ['m2css.css']

[markup]
[markup.goldmark]
  [markup.goldmark.renderer]
    unsafe = true

Below is a pic is the BeyondCompare HTML report showing the diff between my locally Hugo generated index.html and that of the GitLab CICD Pipeline.

Please let me know if you need any other information/documentation.

I wonder whether you have a different version of Hugo locally and in the pipeline, or some difference in your environment?

The way I would approach this is to run the image here registry.gitlab.com/pages/hugo/hugo_extended:latest locally, and generate the site, then diff the two HTML pages on the command line.

You can pin the version of Hugo in the pipeline, with something like image: registry.gitlab.com/pages/hugo/hugo_extended:VERSION.

@snim2, thank you for your response and your help. Here is what I found.

I was originally using Hugo v.0.96.0 locally. So, I bumped down the version in the GitLab Pipeline to the same version. Unfortunately, the GitLab Pipeline artifact HTML was the same, limited result as 0.97.0.

Then, I updated my local version to v.0.97.0 and the generated code was as desired. So, something is different concerning my local environment and GitLab’s Pipeline.

My next step is to change the Hugo theme and see if that will alter the generated outcome.

Thanks again for your help!

1 Like

I wonder whether you’ve just got a file somewhere that hasn’t been committed? Or an env var?

@snim2, No uncommitted files or environment variables.

I suspect it’s the current theme I am using and how it interweaves with the GitLab Pipeline build.

I will keep you posted. Thank you for your help and input.

How did you get on with this?

@snim2,
Thanks for the follow-up. I was waiting until I had some success :face_holding_back_tears:

I applied a different theme and attempted various versions of Hugo in the pipeline build, and still, the generated HTML has only the theme content. I even tried the more recent v.0.97.3.

My next step is to modify the content directory structure. Currently, I have the following off the root content/index.md. I am considering something like: content/stuff/index.md as I have another repo that successfully generates and renders correctly.

I will reply when/if I am successful to update others interested in the solution.

Hmm.

I think it’s highly unlikely to be a problem with the theme or the directory structure.

I can reproduce your bug in a pipeline, and locally in the Docker image that you are using, like this:

$ docker run -it --entrypoint /bin/sh -v ${PWD}:/data registry.gitlab.com/pages/hugo/hugo_extended:latest
# cd /data
# hugo

This is the same Docker image that you’re using in the pipeline, so it really should produce the same output.

hugo --config looks right in both places, and adding debug info and warnings to the pipeline produces this output:

$ hugo --verbose --debug -D --printI18nWarnings --printMemoryUsage --printPathWarnings --printUnusedTemplates
Start building sites … 
hugo v0.97.3-078053a43d746a26aa3d48cf1ec7122ae78a9bb4+extended linux/amd64 BuildDate=2022-04-18T17:22:19Z VendorInfo=gohugoio
INFO 2022/04/20 22:17:29 syncing static files to /
DEBUG 2022/04/20 22:17:29 Render page  to "/index.html"
INFO 2022/04/20 22:17:29 Downloading: https://api.esv.org/v3/passage/text/?include-short-copyright=false&include-headings=false&include-footnotes=false&include-passage-references=false&q=Psalm+97 ...
DEBUG 2022/04/20 22:17:29 found menu: "main", in site config
DEBUG 2022/04/20 22:17:29 found menu: "main", in site config
DEBUG 2022/04/20 22:17:29 Render page Today's Prayer Site to "/index.html"
DEBUG 2022/04/20 22:17:29 creating alias: /page/1/index.html redirecting to https://msquaredweb.gitlab.io/todaysprayer/
DEBUG 2022/04/20 22:17:29 Render page Categories to "/categories/index.html"
DEBUG 2022/04/20 22:17:29 Render page Tags to "/tags/index.html"
DEBUG 2022/04/20 22:17:29 Render XML for "sitemap" to "/sitemap.xml"
DEBUG 2022/04/20 22:17:29 Render 404 page to "/404.html"
DEBUG 2022/04/20 22:17:29 Render page Today's Prayer Site to "/index.xml"
DEBUG 2022/04/20 22:17:29 Render page Categories to "/categories/index.xml"
DEBUG 2022/04/20 22:17:29 Render page Tags to "/tags/index.xml"
                   | EN  
-------------------+-----
  Pages            |  8  
  Paginator pages  |  0  
  Non-page files   |  0  
  Static files     |  2  
  Processed images |  0  
  Aliases          |  1  
  Sitemaps         |  1  
  Cleaned          |  0  
WARN 2022/04/20 22:17:29 Duplicate target paths: /index.html (2)
WARN 2022/04/20 22:17:29 Template _default/_markup/render-image.html is unused, source file /builds/snim2/todaysprayer/themes/PaperMod/layouts/_default/_markup/render-image.html
WARN 2022/04/20 22:17:29 Template _default/archives.html is unused, source file /builds/snim2/todaysprayer/themes/PaperMod/layouts/_default/archives.html
WARN 2022/04/20 22:17:29 Template _default/index.json is unused, source file /builds/snim2/todaysprayer/themes/PaperMod/layouts/_default/index.json
WARN 2022/04/20 22:17:29 Template _default/search.html is unused, source file /builds/snim2/todaysprayer/themes/PaperMod/layouts/_default/search.html
WARN 2022/04/20 22:17:29 Template partials/comments.html is unused, source file /builds/snim2/todaysprayer/themes/PaperMod/layouts/partials/comments.html
WARN 2022/04/20 22:17:29 Template partials/home_info.html is unused, source file /builds/snim2/todaysprayer/themes/PaperMod/layouts/partials/home_info.html
WARN 2022/04/20 22:17:29 Template partials/index_profile.html is unused, source file /builds/snim2/todaysprayer/themes/PaperMod/layouts/partials/index_profile.html
WARN 2022/04/20 22:17:29 Template partials/post_nav_links.html is unused, source file /builds/snim2/todaysprayer/themes/PaperMod/layouts/partials/post_nav_links.html
WARN 2022/04/20 22:17:29 Template partials/share_icons.html is unused, source file /builds/snim2/todaysprayer/themes/PaperMod/layouts/partials/share_icons.html
WARN 2022/04/20 22:17:29 Template partials/social_icons.html is unused, source file /builds/snim2/todaysprayer/themes/PaperMod/layouts/partials/social_icons.html
WARN 2022/04/20 22:17:29 Template partials/svg.html is unused, source file /builds/snim2/todaysprayer/themes/PaperMod/layouts/partials/svg.html
WARN 2022/04/20 22:17:29 Template partials/templates/opengraph.html is unused, source file /builds/snim2/todaysprayer/themes/PaperMod/layouts/partials/templates/opengraph.html
WARN 2022/04/20 22:17:29 Template partials/templates/schema_json.html is unused, source file /builds/snim2/todaysprayer/themes/PaperMod/layouts/partials/templates/schema_json.html
WARN 2022/04/20 22:17:29 Template partials/templates/twitter_cards.html is unused, source file /builds/snim2/todaysprayer/themes/PaperMod/layouts/partials/templates/twitter_cards.html
WARN 2022/04/20 22:17:29 Template partials/toc.html is unused, source file /builds/snim2/todaysprayer/themes/PaperMod/layouts/partials/toc.html
WARN 2022/04/20 22:17:29 Template robots.txt is unused, source file /builds/snim2/todaysprayer/themes/PaperMod/layouts/robots.txt
WARN 2022/04/20 22:17:29 Template shortcodes/blockquote.html is unused, source file /builds/snim2/todaysprayer/themes/PaperMod/layouts/shortcodes/blockquote.html
WARN 2022/04/20 22:17:29 Template shortcodes/category-menu.html is unused, source file /builds/snim2/todaysprayer/layouts/shortcodes/category-menu.html
WARN 2022/04/20 22:17:29 Template shortcodes/collapse.html is unused, source file /builds/snim2/todaysprayer/themes/PaperMod/layouts/shortcodes/collapse.html
WARN 2022/04/20 22:17:29 Template shortcodes/figure.html is unused, source file /builds/snim2/todaysprayer/themes/PaperMod/layouts/shortcodes/figure.html
WARN 2022/04/20 22:17:29 Template shortcodes/ltr.html is unused, source file /builds/snim2/todaysprayer/themes/PaperMod/layouts/shortcodes/ltr.html
WARN 2022/04/20 22:17:29 Template shortcodes/rawhtml.html is unused, source file /builds/snim2/todaysprayer/themes/PaperMod/layouts/shortcodes/rawhtml.html
WARN 2022/04/20 22:17:29 Template shortcodes/requests.html is unused, source file /builds/snim2/todaysprayer/layouts/shortcodes/requests.html
WARN 2022/04/20 22:17:29 Template shortcodes/rtl.html is unused, source file /builds/snim2/todaysprayer/themes/PaperMod/layouts/shortcodes/rtl.html
Total in 265 ms

So, it seems that the information from the APIs that you are using is being fetched, but even so, nothing is appearing in the <main></main> section of your index page. I’m not sure whether the duplicate target paths is just this issue or something else.

This isn’t an answer to your problem, but this is the kind of debugging you need to be thinking about.

@snim2, You are correct when you state, “…but this is the kind of debugging you need to be thinking about.” Thank you for the Hugo debug options from the CLI. I learn something everyday. :blush:

@snim2,
When in the Docker image locally as you did, I noted the following warning during the build:

WARN 2022/04/21 11:07:00 found no layout file for "HTML" for kind "page": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN 2022/04/21 11:07:00 found no layout file for "HTML" for kind "home": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN 2022/04/21 11:07:00 found no layout file for "HTML" for kind "taxonomy": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN 2022/04/21 11:07:00 found no layout file for "HTML" for kind "taxonomy": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.

I will look into this and debug it as well.

The fact is, this is not a priority as I have moved the repo to GitHub and am deploying it as an Azure Static Web App now.

With that stated, I really do appreciate your help as I stated previously, I have learned from your posts.

No worries. I think your problem is either some missing config, or the duplicate target paths.

I notice that on my local machine and in the pipeline some of the output is in a different order. If I move your content/index.md to content/home.md then the file generated at public/home/index.html contains the HTML that should be in <main></main>.

Yeah, as you know previously, I wanted to modify the content directory structure. I was considering something like: content/stuff/index.md as I have another repo that successfully generates and renders correctly as it follows what I understand to follow the Hugo lookup order and layout. I had already attempted to rename the content/index.html to content/_index.html to no avail.

I will try content/stuff.md myself and see.

Oh, this is interesting. Renaming content/index.md to content/_index.md worked for me, I guess because I made other changes to the Hugo config. I’ve raised an MR for you.

@snim2, Can you share your config.toml content?

It’s in the MR I raised for you.

@snim2,
Your config updates and the renaming content/index.md to content/_index.md was the answer!

1 Like