hugo-universal-theme icon indicating copy to clipboard operation
hugo-universal-theme copied to clipboard

_index.md content not showing

Open brianking opened this issue 8 years ago • 14 comments

I create a section landing page with an _index.md file:

e.g. hugo new about/_index.md

There are 2 issues:

  1. Content in the file does not appear, i.e. the page is blank. It is the correct file because the page title appears correctly.
  2. The page has pagination. I would not need this on pages outside the blog.

Neither of these issues happens if the page is named something other than _index.md.

brianking avatar Jun 21 '17 16:06 brianking

Hello :) I have cloned and replaced the configuration tolm from examplesite into the folder of "new site" and folder themes to know like it looks on my browser but it just appears the icons and the header :(

C:\Hugo\Sites\tercero>hugo.exe server --theme=hugo-universal-theme --buildDrafts Started building sites ... ERROR 2017/06/24 06:37:28 Error while rendering "home": template: theme/index.html:18:11: executing "theme/index.html" at <partial "carousel.ht...>: error calling partial: template: theme/partials/carousel.html:3:10: executing "theme/partials/carousel.html" at <len .Site.Data.carou...>: error calling len: len of untyped nil Built site for language en: 0 draft content 0 future content 0 expired content 0 regular pages created 6 other pages created 0 non-page files copied 0 paginator pages created 0 tags created 0 categories created total in 34 ms

Karolinehc avatar Jun 23 '17 19:06 Karolinehc

@Karolinehc if you already have not found a fix yet take a look.

kwamenna avatar Oct 13 '17 16:10 kwamenna

@MorseGates thanks a lot :)

Karolinehc avatar Oct 13 '17 18:10 Karolinehc

Hi all and thanks for your time/work.

I've been trying to use this theme but apparently this is still lacking support for the problem stated by @brianking . Is there any plan to fix it ?

Regards, Xavi

xpegenaute avatar Jul 13 '18 23:07 xpegenaute

Hi,

looking the documentation I found: https://gohugo.io/commands/hugo_new/#synopsis it says:

If archetypes are provided in your theme or site, they will be used.

We are using archetypes, so maybe is not compatible.

Regards.

ryanfox1985 avatar Jul 14 '18 08:07 ryanfox1985

Hi,

apparently it is nor related. I moved the default.md from the archetypes dir outside of the hugo installation, emptied all the archetypes dirs and tried again. I did'nt work either.

Thanks & regards, Xavi

xpegenaute avatar Jul 14 '18 11:07 xpegenaute

Think Hugo might be daft and search for the folder, regardless of whether it has contents?

Try deleting the entire container too and see if there's a different result? Rather than emptying.

GeorgeWL avatar Jul 16 '18 08:07 GeorgeWL

Had same problem like this on the Hugo Coder Theme. Rather than render as a page, it render as a list page.

nnfans avatar Apr 28 '19 23:04 nnfans

You can add {{ .Content}} to the list template and it will render the contents of your _index.md file that sits in a folder where content is root.

jesselawson avatar Sep 18 '19 01:09 jesselawson

I am getting some pretty weird behavior using the Academic theme (https://sourcethemes.com/academic/docs/): _index.md MIGHT show the content if I do {{ .Content}} but it also might not. Hugo seems to be picking and choosing what is a 'page' vs a 'regular page' and only 'regular pages' have any content in them. Here is one of the folders in the content folder:

>posts
>>post-1
>>>_index.md
>>post-2
>>>_index.md
>>post-3
>>>_index.md
>>_index.md

So the top level _index.md shows up with post-1, 2, and 3 correctly. And when I click on each of them the title shows up for those pages. Except only post-3 shows the content. The other two show empty... Why? Not really sure.

One problem is that Hugo is rendering layouts/posts/list.html instead of layouts/posts/single.html in the single view!

Another problem is that Hugo thinks that an arbitrary post is a regular page whereas all of the other ones are not (so {{ .Content}} is empty).

Puzzling...

ivanbportugal avatar Oct 01 '19 03:10 ivanbportugal

In case you guys might be wondering: Hugo HIDES future content. That's what the problem was with mine. So, if you date your post after today, you need to build it with the -F argument:

hugo server -F

:: bangs head on keyboard ::

ivanbportugal avatar Oct 01 '19 03:10 ivanbportugal

so resolved?

GeorgeWL avatar Oct 01 '19 08:10 GeorgeWL

Content in the file does not appear, i.e. the page is blank. It is the correct file because the page title appears correctly.

As @jesselawson indicated, the way to do this is by adding the following

<div id="post-content">
{{ .Content }}
</div>

inside of the file titled: list.html

You can find the file here: your-site > themes > hugo-universal-theme > layouts > _default > list.html

You probably wish to add it below the following line: https://github.com/devcows/hugo-universal-theme/blob/00e1f20103c31bc2908f4c3e20b98093e6012241/layouts/_default/list.html#L23

If you have content, it will now show up. If you have no content in the _index.md file, your page will look as expected.

Lokdei avatar Dec 17 '21 00:12 Lokdei

I ran into a similar issue with another theme. _index.md would sometimes get the list.html layout and other-times the terms.html layout (which was empty for me). I fixed it by manually specifying layout: list in _index.md's front matter.

I'd have to dig deeper to figure out why the lookup-order isn't working deterministically. But since I only have a few _index files I'm not too worried about manually overriding.

quintinm-dev avatar May 18 '22 06:05 quintinm-dev