gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
75.12k stars 7.48k forks source link

list.html in local directory does not override version in theme #661

Closed oriolmirosa closed 9 years ago

oriolmirosa commented 9 years ago

I'm completely new to Hugo and to programming in general, so I'm sorry if this is a stupid question. I have tried to find an answer, and I am only posting here because I have been unsuccessful.

I am building a website and, in the local directory, I have created single.html and list.html files in /layouts/blog to use for my blog instead of the version in the theme (I am using redlounge). I basically copied the files from the theme, and I am modifying them in the local directory. However, once I make changes, the local single.html correctly overrides the one in the theme, but that is not the case for list.html. It is as if Hugo only looked for list.html in the theme. In fact, if I rename the version in the theme, the one in the local directory is still not used.

I assumed this had to be a mistake on my part, but since single.html works as expected I am not sure what I can be doing wrong. Any ideas?

(I'm using v0.12)

k4rtik commented 9 years ago

Guess #637 fixes this. You may want try to reproduce on master or apply patch for b716dbe.

oriolmirosa commented 9 years ago

I'm now running v0.13-DEV buildDate: 2014-11-22T00:18:49-06:00 and the problem remains.

k4rtik commented 9 years ago

You are right, this is reproducible. If I put a list.html template in layouts/_default it works, but not if I put that in layouts/post.

k4rtik commented 9 years ago

gohugo.io site seems down now, but I checked the documentation, it says the following about section lists:

Section Lists

A Section will be rendered at /SECTION/

So, you need to put your list.html for blog as layouts/section/blog.html.

oriolmirosa commented 9 years ago

Thanks for your note. I have tried all those options you mention above, and the only one that works is the third one, which is precisely the one you say worked: /layouts/_default/list.html

For all the other ones (as well as what I was originally trying: /layouts/section/list.html) the version from the theme continues to take precedence. Using /layouts/_default/list.html does not help me if what I want is to have different list.html templates for different sections. Moreover, and as I said in a previous message, this happens only with list.html, and not with single.html, so at the very least there is an inconsistency here.

k4rtik commented 9 years ago

Are you sure /layouts/section/blog.html also didn't work for you, assuming "blog" is your section name?

It worked just fine in my case, I had /layouts/section/post.html for my post section listing.

oriolmirosa commented 9 years ago

You are absolutely right. I was actually taking the 'section' part of the URL as SECTION, and so I was putting the file in: /layouts/blog/blog.html or /layouts/blog.list.html instead of: /layouts/section/blog.html Now I can do what I want. Thanks!

k4rtik commented 9 years ago

Though this resolved the issue for you, I think the current order of template search is pretty confusing for the end user. It should be uniform across sections and taxonomy. I will try and look into this in detail sometime.

k4rtik commented 9 years ago

On second look at the documentation at http://gohugo.io/templates/list/ it seems pretty clear once one understands the meaning of a section, taxonomy (singular & plural) and a taxonomy term.

Found a minor mistake in the doc, sent PR for the same.

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.