Themes don't apply in built pages but do in hugo server

Hi, I’m using hugo version 0.85.0 with the hugo-book theme.

I’m rather new to hugo so I don’t really know what I’m doing. I used the install instructions here to install this theme.

My problem is when using hugo server it works but when I just run hugo to build the site it doesn’t load my theme.

I also tried using the example site from the theme’s github.

The site only shows the html. When I look under style in firefox nothing shows up. It does show up when using hugo server so I know it should be there. If I create a new style manually and past from the hugo server generated page it looks correct.

It confuses me that it works in the live build but not when generating the static pages. GitLab pages CI gives the same result.

I’ve tried other themes and they also do the same thing so I don’t think it’s books fault.

Any ideas would be much appreciated. My config.yaml file is below along with hugo’s output when running hugo in the sites root directory.

# hugo server --minify --themesDir ... --baseURL=

title: Title
theme: book

# Book configuration
disablePathToLower: true
enableGitInfo: true

# Needed for mermaid/katex shortcodes
      unsafe: true
    startLevel: 1

# Multi-lingual mode config
# There are different options to translate files
# See
# And

  # (Optional, default light) Sets color theme: light, dark or auto.
  # Theme 'auto' switches between dark and light modes based on browser/os preferences
  BookTheme: "auto"

  # (Optional, default true) Controls table of contents visibility on right side of pages.
  # Start and end levels can be controlled with markup.tableOfContents setting.
  # You can also specify this parameter per page in front matter.
  BookToC: true

  # (Optional, default none) Set the path to a logo for the book. If the logo is
  # /static/logo.png then the path would be logo.png
  BookLogo: Logo.png

  # (Optional, default none) Set leaf bundle to render as side menu
  # When not specified file structure and weights will be used
  BookMenuBundle: /menu

  # (Optional, default docs) Specify root page to render child pages as menu.
  # Page is resoled by .GetPage function:
  # For backward compatibility you can set '*' to render all sections to menu. Acts same as '/'
  BookSection: docs

  # Set source repository location.
  # Used for 'Last Modified' and 'Edit this page' links.

  # (Optional, default 'commit') Specifies commit portion of the link to the page's last modified
  # commit hash for 'doc' page type.
  # Requires 'BookRepo' param.
  # Value used to construct a URL consisting of BookRepo/BookCommitPath/<commit-hash>
  # Github uses 'commit', Bitbucket uses 'commits'
  BookCommitPath: commit

  # Enable "Edit this page" links for 'doc' page type.
  # Disabled by default. Uncomment to enable. Requires 'BookRepo' param.
  # Edit path must point to root directory of repo.
  BookEditPath: edit/master/

  # Configure the date format used on the pages
  # - In git information
  # - In blog posts
  BookDateFormat: "January 2, 2006"

  # (Optional, default true) Enables search function with flexsearch,
  # Index is built on fly, therefore it might slowdown your website.
  # Configuration for indexing can be adjusted in i18n folder per language.
  BookSearch: false

  # (Optional, default true) Enables comments template on pages
  # By default partals/docs/comments.html includes Disqus template
  # See
  # Can be overwritten by same param in page frontmatter
  BookComments: false
Start building sites … 
hugo v0.85.0+extended linux/amd64 BuildDate=unknown
WARN 2021/08/04 13:20:31 Bundle menu mode is deprecated and will be removed

                   | EN  
  Pages            | 16  
  Paginator pages  |  0  
  Non-page files   |  0  
  Static files     | 91  
  Processed images |  0  
  Aliases          |  2  
  Sitemaps         |  1  
  Cleaned          |  0  

Total in 28 ms

How are you viewing the site after you build it?

Opening the public/index.html file in firefox.

Yeah, it is not going to work that way, unless the theme was designed with that usage in mind.

The files in the public directory need to be served (NGINX, Apache, etc.).

Ok, so why doesn’t it work with gitlab pages then? I have an nginx server so I’ll test that in a minute.

Open dev tools in the browser to see the error(s).

Also, set your baseURL.

I am seeing 404s 404s which is the only css. So this might be the baseurl? That URL isn’t the one that my site is being served from.

What is the URL that your site is being served from?

I just built it with my the baseurl pointing to my nginx server domain and it works! My Gitlab CI is failing now and I’m not sure why. I think it can’t find git. ERROR 2021/08/04 20:12:36 Failed to read Git log: Git executable not found in $PATH So probably not a hugo thing.

Correct. Not a Hugo thing.

@jmooring Thanks so much for the help!

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