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

HUGO_THEME succeeds but "-t" fails when config.toml contains theme = ["../.."] #5061

Closed
anthonyfok opened this Issue Aug 11, 2018 · 3 comments

Comments

Projects
None yet
3 participants
@anthonyfok
Copy link
Contributor

anthonyfok commented Aug 11, 2018

I'm not entirely sure it is a Hugo bug at all because it looks like a rare corner case which manifests only when config.toml has a buggy theme entry, as described below.

But HUGO_THEME and -t being inconsistent here seems worthy of investigation, though admittedly a low-priority one.

Details

I came across a perculiar error (tested with Hugo 0.46) when building the Hugo themes site locally with the alpha-church theme after I reverted the HUGO_THEME workaround back to using the -t flag (see gohugoio/hugoThemes@0b4e98b):

 ==== PROCESSING  alpha-church  ====== 
Building site for theme alpha-church using its own exampleSite to ../themeSite/static/theme/alpha-church/
hugo --quiet -s exampleSite2 -d ../themeSite/static/theme/alpha-church/ -t alpha-church -b http://localhost:1313/theme/alpha-church/
ERROR 2018/08/11 10:22:56 Unable to locate template for shortcode "osmap" in page "about.md"
ERROR 2018/08/11 10:22:56 Unable to locate template for shortcode "contact_form" in page "contact.md"
Error: Error building site: logged 2 error(s)
FAILED to create exampleSite for alpha-church

However, if I add HUGO_THEME=alpha-church, the "Unable to locate template for shortcode" errors go away.

I then noticed in https://github.com/funkydan2/alpha-church/blob/master/exampleSite/config.toml#L4
a somewhat strange theme = ["../.."] entry (themesDir not defined in config.toml):

baseURL = "http://example.org/"
languageCode = "en-us"
title = "Alpha Church"
theme = ["../.."]

# etc.

It looks like an erroneous use of the theme variable, and I suppose it should be corrected to something like this:

theme = "alpha-church"
themesDir = "../.."

But HUGO_THEME and -t being inconsistent here seems worthy of investigation, though admittedly a low-priority one.

@nonumeros

This comment has been minimized.

Copy link

nonumeros commented Aug 14, 2018

The error I'm getting in my end and without modifying any part of the config code, is the following: it fails with both -t flag and without the -t flag it fails also.

No errors are returned with either the suggested change of having theme = "alpha-church" or by having the delimiters in place. Because it makes no difference.

HUGO_THEME succeeds but "-t" fails when config.toml contains theme = ["../.."]

Nope. What you described on your title heading is not what I'm getting.

As a matter of fact, it's the opposite.

And it doesn't matter whether you'd use -t or not. It still returns the errros.

Without theme defined on the configuration file, serve returns the error, while -t flag doesn't.

And with themes in place and without modifying any other part of the configuration file, serve returns the error, while -t doesnt. So this is the only consistent behavior that one would get from this issue.

With themes it doesn't matter whether the delimiters are in use or not on the configuration file.

And I really don't know what the issue is with the path configuration on the configuration file. I concur with the author in that case. (As long as themes as environment variable and not theme is used on the config file). So I can't really follow you there. Wish I could, but not this time around. That is, if you are running hugo from the exampleSite directory, it's perfectly understandable to have separated values for that path on that configuration file e.g [../..]. If for example, you were to remove the theme itself from the themes directory then the no less expected error that is unable to find the theme directory comes back.

This has nothing to do with the delimiters in use. And I'm not saying that is not erroneous to use them.

@nonumeros

This comment has been minimized.

Copy link

nonumeros commented Aug 14, 2018

Perhaps this is an ongoing problem that should be more carefully looked up.

Take for example https://github.com/matcornic/hugo-theme-learn

And assuming that a themes directory is created within the exampleSite

go to the config file on exampleSite directory and change it to

 #theme = "hugo-theme-learn"
 theme = "../.."
 #themesdir = "../.."

Both the -t flag and serve compile

Now, if I were to change it to:

 #theme = "hugo-theme-learn"
 themes = "../.."
 #themesdir = "../.."

the -t flag compiles, while serve doesn't.

Whereas the delimiters are in use make no difference.

funkydan2 added a commit to funkydan2/alpha-church that referenced this issue Aug 25, 2018

digitalcraftsman added a commit to gohugoio/hugoThemes that referenced this issue Aug 30, 2018

Readd temporary workaround for setting theme path
Setting the theme path via the `-t THEME` flag isn't recognized
and still requires to use the HUGO_THEME env variable as workaround.

See #412
See gohugoio/hugo#5061
See gohugoio/hugo#4851

anthonyfok added a commit to gohugoio/hugoThemes that referenced this issue Sep 12, 2018

Re-apply temporary workaround to generateThemeSite.sh
@digitalcraftsman was trying to re-apply this workaround
in commit 3068f64,
but for some reason that commit contains whitespace cleanup only.
The following commit message was from that commit:

Setting the theme path via the `-t THEME` flag isn't recognized
and still requires to use the HUGO_THEME env variable as workaround.

See #412
See gohugoio/hugo#5061
See gohugoio/hugo#4851

This reverts commit 0b4e98b.
@stale

This comment has been minimized.

Copy link

stale bot commented Dec 12, 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 12, 2018

@anthonyfok anthonyfok added Bug and removed Stale labels Jan 12, 2019

tryzniak added a commit to tryzniak/hugo that referenced this issue Jan 13, 2019

Make hugo server -t work again
This commit solves an issue where hugo would ignore the cli -t flag
and only use a theme defined in config.toml.

Also allow -t flag to accept a string slice.

Closes gohugoio#5569
Closes gohugoio#5061
Related gohugoio#4868

@bep bep closed this in #5603 Jan 13, 2019

bep added a commit that referenced this issue Jan 13, 2019

Make hugo server -t work again
This commit solves an issue where hugo would ignore the cli -t flag
and only use a theme defined in config.toml.

Also allow -t flag to accept a string slice.

Closes #5569
Closes #5061
Related #4868

@bep bep added this to the v0.54 milestone Jan 13, 2019

nguyenvanduocit added a commit to 12bitvn/hugo that referenced this issue Jan 18, 2019

Make hugo server -t work again
This commit solves an issue where hugo would ignore the cli -t flag
and only use a theme defined in config.toml.

Also allow -t flag to accept a string slice.

Closes gohugoio#5569
Closes gohugoio#5061
Related gohugoio#4868
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment