New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Site build fails if theme uses data/ in theme dir, but theme set using CLI instead of in config #4649

Open
kaushalmodi opened this Issue Apr 19, 2018 · 6 comments

Comments

Projects
None yet
5 participants
@kaushalmodi
Copy link
Member

kaushalmodi commented Apr 19, 2018

The failure happens when:

  1. The data/ file is present in the theme dir
  2. Index of that data map is specified in the config.toml of the theme.
  3. theme is not set in the site's config.toml, but is instead passed through the -t flag.

The build works as soon as the point 3 above is changed to:

  • Set the theme in the site's config.toml instead of passing it via -t.

Steps to reproduce

  1. git clone https://gitlab.com/kaushalmodi/hugo-throwaway-3
  2. cd hugo-throwaway-3
  3. hugo -t test-theme

You will see this error:

Building sites … ERROR 2018/04/19 12:30:04 Error while rendering "home" in "": template: theme/index.html:7:3: executing "theme/index.html" at <index .Site.Data.foo...>: error calling index: value is nil; should be of type string

Now set the theme in config instead of via -t

  1. echo 'theme = "test-theme"' >> config.toml
  2. hugo (Note that now the theme is not set on command line)

You will get:

                   | EN
+------------------+----+
  Pages            |  4
  Paginator pages  |  0
  Non-page files   |  0
  Static files     |  0
  Processed images |  0
  Aliases          |  0
  Sitemaps         |  1
  Cleaned          |  0

Some debug

The error occurs when an element in the theme's data is accessed using a param set in the theme's config.toml.

So this works:

{{ index .Site.Data.foo "one" }}

but this doesn't (only when setting theme via -t):

{{ index .Site.Data.foo (.Param "sel") }}

(From the demo site's index.html)


Hugo version: Hugo Static Site Generator v0.40-DEV-74520D2C


/cc @paskal

@kaushalmodi kaushalmodi changed the title Site build fails if theme uses data/ in theme dir, but theme var not set in site config Site build fails if theme uses data/ in theme dir, but theme set using CLI instead of in config Apr 19, 2018

@kaushalmodi

This comment has been minimized.

Copy link
Member

kaushalmodi commented Apr 19, 2018

I've verified this bug to exist on 0.38.2 too. So this doesn't have anything to do with the CLI cleanup in 0.39.

@moorereason moorereason added the Bug label Apr 19, 2018

@nonumeros

This comment has been minimized.

Copy link

nonumeros commented May 28, 2018

I only get this error is by omitting the params value on the site config file, else is not there (0.40.3)

0.38.1 and 0.38.2 return the error though

@funkydan2

This comment has been minimized.

Copy link

funkydan2 commented Jun 20, 2018

I'm not sure if this is the same issue, but I'm having trouble with Hugo not parsing files in my theme's data directory.

For me, this error is a regression in a recent version, first noticed in 42.1

Steps to reproduce

  1. Clone https://github.com/funkydan2/alpha-church
  2. Run hugo server from the exampleSite directory
  3. The site appears to build, but viewing localhost:1313 in a browser displays errors in the data console where hugo hasn't inserted data from libs.toml
  4. However, if you copy libs.toml from the theme data directory to the data directory in exampleSite, the site builds and works correctly.

@kaushalmodi, I don't know if my bug is related, but it sounded similar enough. I'll open a new issue is you think it's not the same thing.

@dzello

This comment has been minimized.

Copy link

dzello commented Jul 2, 2018

Having the same issue as @funkydan2 here, first noticed in 0.42 (0.3x works fine).

I can reproduce it by running the reveal-hugo exampleSite. Site.Data is empty instead of having values from ../data/reveal_hugo.toml (../ points to the theme, one directory up from exampleSite).

@funkydan2

This comment has been minimized.

Copy link

funkydan2 commented Aug 25, 2018

For me, the problem appears to be fixed by getting the themesDir and theme variables set correctly in config.toml.

For more info, see #5061

@stale

This comment has been minimized.

Copy link

stale bot commented Dec 23, 2018

This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help.
If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.
If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.
This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.

@stale stale bot added the Stale label Dec 23, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment