Hugo 0.18 ignores index.md in the section

If the section contains a custom index.md into the section, Hugo ignores it and replaces to the standard list. It’s specially conceived? Or exist a possibility to use a custom index.md in the section?
Version 0.17 correctly processed index.md in the section.

Support for the customs index.md for ever disabled in the Hugo?

No, it is better than ever – you don’t have to use to common index.md hack. Use _index.md instead.

I am confused by how it behaves now.

Consider the now-broken theme β€œphugo”. It’s albums used to work perfectly fine with index.md, like here.

With Hugo 0.18 that index.md renders with a list layout - but not ignored, see the effect here. If I rename it to _index.md it seemds to be ignored altogether - neither list, nor single.

If the albums moved into a subfolder , so they are not considered sections they work fine. with index.md being rendered as a single.

What do I miss? Or at least, what is a migration path to accommodate new behaviour? Adding another directory layer is highly undesirable.

1 Like

_index.md not work for sections, it’s work for taxonomies only.

@bep, so if _index.md does not work in sections, what do you mean as

So far I do not see how that breaking change can be reasonably accommodated in phugo. May be some hints can be placed in an index.md front matter to steer rendering? What else may be done?

I do not understand why do we need an _index.md in the sections if there already exist the index.md with front matter and content.

I do not either, except for @bep have seemed to suggest to use it. I may have missed a context of the suggestion though. The point is that index.md no longer works with hugo 0.18 the way it did with hugo 0.17 in phugo theme and I am trying to undestand what can be done to fix it.

_index.md works for sections, home page, taxonomy terms, taxonomy lists. That should cover all the current use cases.

I’m on Christmas holiday now, so that is the answer you get from me.

Read the documentation. If that is not good enough, please file an issue on GitHub so we can fix it, so we don’t have to answer the same questions again and again. Then you can keep on using Hugo 0.17 until you understand how to upgrade.

Believe me when I say this: Hugo 0.18 is a big, big improvement – and this means that you can remove your index.md hacks, which, to be honest, you where kind of lucky that worked for sections in 0.17 (the page were generated after the section so index.html overwrote index.html).

OK, opened the relevant issue 2827.

Good.

Sorry for my Ebenezer Scrooge tone in my replies earlier – I have spent many hours thinking and implementing this, and I sometimes forget that this may not be obvious to those who have not.

Merry Xmas to all Hugoers!

4 Likes

Sorry to come back on this, but I think that my problem is linked with it:

@bep wrote in Hugo 0.18 Released: Everything Now a Page, and Twice as Fast!:

index.md or foo.md is content and metadata for the single pages, _index.md of content and metadata for the β€œnode” pages – aka the list pages (if you include the home page in that definition).

I find this working: create a /section/index.md in a section and it renders to /section/index.html in that same section in the public folder.

But when I use this

<ul> 
            {{ $act_section := .Section}}                  
            {{ range where .Site.Pages "Section" $act_section }}       
        	<li><a href="{{ .RelPermalink }}">{{- .LinkTitle -}}</a></li>    
            {{ end }}      
</ul>

to create a section navigation it uses linktitle from the frontmatter of /section/index.md but the created link instead points to /section.html which gives a simple list but not the content of /section/index.md.
If I just rename /section/index.md to something else like /section/intro.md everything works fine.
(But then, off course, I have to tweak the server config to use intro.html as default page also which I personally do not prefer).

v0.18.1 BuildDate: 2016-12-30T11:05:34+01:00
uglyURLs = true
relativeURLs = true
canonifyURLs = false

I’m not totally sure what you’re trying to do, but did you check out the .GetPage function? Also remember the section page is _index.md and not index.md. I’d write some sample code but am on my phone. Also there is .Pages and .RegularPages…

From the above [quote="@bep"]
index.md or foo.md is content and metadata for the single pages,
[/quote] I expected that index.md would render as index.html which indeed it does. I like to have an index-file in each content subdirectory as every webserver I know will deliver this when a user uses an address like http://domain.tld/section/.
All works fine so far.

I’ll give you the structure:

.
β”œβ”€β”€ config.toml
β”œβ”€β”€ archetypes
β”œβ”€β”€ content
|   β”œβ”€β”€ _index.md
|   β”œβ”€β”€ motorhome
|   |   β”œβ”€β”€ index.md
|   |   β”œβ”€β”€ engine.md
|   |   β”œβ”€β”€ solar.md
|   |   └── chassis.md
|   β”œβ”€β”€ dogs
|   β”œβ”€β”€ blog
|   └── contact
β”œβ”€β”€ static
β”œβ”€β”€ data
β”œβ”€β”€ layouts
└── themes

and this renders to

.
└── public
    β”œβ”€β”€ index.html
    β”œβ”€β”€ motorhome.html
    β”œβ”€β”€ motorhome
    |   β”œβ”€β”€ index.html
    |   β”œβ”€β”€ engine.html
    |   β”œβ”€β”€ solar.html
    |   └── chassis.html
    β”œβ”€β”€ dogs.html
    β”œβ”€β”€ dogs
    β”œβ”€β”€ blog.html
    β”œβ”€β”€ blog
    β”œβ”€β”€ contact.html
    └── contact

which is ok so far - and as expected following @bep 's definition.

Now I use above code to produce a sidenav within the motorhome section. It ends up like this:

<li><a href="../motorhome.html">Index</a></li>                   
<li><a href="../motorhome/engine.html">Engine</a></li>            
<li><a href="../motorhome/solar.html">Solar</a></li>            
<li><a href="../motorhome/chassis.html">Chassis</a></li>  

which obviously is wrong since the first line should be like

<li><a href="../motorhome/index.html">Index</a></li>                   

So at least for creating the menue index.md is NOT treated as content and metadata for a single page.

What above code?