Missing files when doing `hugo` vs `hugo server`

Hi,

We are currently building our docs and now are working on creating a jenkins pipeline for deployment.

The site that was deployed through jenkins is broken but is working locally. We noticed some files were missing or not generated.

In jenkins build stage we do,

ip-172-31-40-217:~/docs/docs-poc/docs-poc$ hugo -D --baseURL http://docs.example.com/ta/v3.0.0
Start building sites … 
hugo v0.140.2-aae02ca612a02e085c08366a9c9279f4abb39d94+extended linux/amd64 BuildDate=2024-12-30T15:01:53Z VendorInfo=gohugoio

WARN  "/home/hugo/docs/docs-poc/docs-poc/content/en/ta/_index.html:1:1": duplicate menu entry with identifier "Docs" in menu "main"

                   | EN | FA | NO  
-------------------+----+----+-----
  Pages            | 97 |  8 |  8  
  Paginator pages  |  0 |  0 |  0  
  Non-page files   |  1 |  1 |  1  
  Static files     | 53 | 53 | 53  
  Processed images |  2 |  0 |  0  
  Aliases          |  1 |  0 |  0  
  Cleaned          |  0 |  0 |  0  

Total in 4433 ms
ip-172-31-40-217:~/docs/docs-poc/docs-poc$ ls -l public/scss/
total 1836
-rw-rw-r-- 1 hugo hugo 1476896 Mar 10 12:04 main.css.map
-rw-rw-r-- 1 hugo hugo 400232 Mar 10 12:16 main.min.f6466d5ff970591c368c6352dfd1f3917c822ffe560ff84f087907ea726ba489.css

In local development we do,
hugo server -D --baseURL=http://localhost:1313/v3 --appendPort=false
This works as expected.

So i tried to publish the public directory generated by this command

ip-172-31-40-217:~/docs/docs-poc/docs-poc$ hugo server -D --baseURL=http://localhost:1313/v3 --appendPort=false
Watching for changes in /home/hugo/docs/docs-poc/docs-poc/{archetypes,assets,content,data,layouts,package.json,static}
Watching for config changes in /home/hugo/docs/docs-poc/docs-poc/hugo.toml, /home/hugo/docs/docs-poc/docs-poc/go.mod
Start building sites … 
hugo v0.140.2-aae02ca612a02e085c08366a9c9279f4abb39d94+extended linux/amd64 BuildDate=2024-12-30T15:01:53Z VendorInfo=gohugoio

WARN  "/home/hugo/docs/docs-poc/docs-poc/content/en/ta/_index.html:1:1": duplicate menu entry with identifier "Docs" in menu "main"

                   | EN | FA | NO  
-------------------+----+----+-----
  Pages            | 97 |  8 |  8  
  Paginator pages  |  0 |  0 |  0  
  Non-page files   |  1 |  1 |  1  
  Static files     | 53 | 53 | 53  
  Processed images |  2 |  0 |  0  
  Aliases          |  1 |  0 |  0  
  Cleaned          |  0 |  0 |  0  

Built in 2814 ms
Environment: "development"
Serving pages from disk
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
Web Server is available at http://localhost:1313/v3/ (bind address 127.0.0.1) 
Press Ctrl+C to stop
ip-172-31-40-217:~/docs/docs-poc/docs-pocls -l public/scss/
total 1916
-rw-rw-r-- 1 hugo hugo 485620 Mar 10 12:25 main.css
-rw-rw-r-- 1 hugo hugo 1471450 Mar 10 12:25 main.css.map

Are we doing some thing wrong? What should be the correct command for building hugo as part of jenkins?

EDIT:
Version: hugo v0.140.2-aae02ca612a02e085c08366a9c9279f4abb39d94+extended linux/amd64 BuildDate=2024-12-30T15:01:53Z VendorInfo=gohugoio
Theme: Docsy
Missing file main.css under public/scss when doing just hugo build vs hugo server

Thank you

First: it’s never a good idea to publish stuff generated using hugo server.

A local hugo with the same arguments as that on jenkins should give the same result → if not something is different there (hugo, repo state…). Keep in mind that public is not cleared so you might have stuff from older runs locally.

Without having access to your jenkins logs and source repo here’s an educated guess.

Looks like you don’t really miss the main.css file in /public/scss but expact a different name.

  • hugo server (development environment) generates → main.css
  • hugo (production environment) generates →
    main.min.f6466d5ff970591c368c6352dfd1f3917c822ffe560ff84f087907ea726ba489.css

looks like you have a conditional logic within the templates which minifies and fingerprints the resource in production but not in development hugo.Environment.

so if that is your problem, seems you have included the css hardcoded as main.css in some templates/partials. Use the .RelPermalink of the ressource instead.

1 Like

Thanks @irkode. You are right.

This is due to hardcoded main.css and the conditional logic for Production that was not there in dev.

Thanks again. Appreciate the help.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.