Skip to content

Handle uglyURLs ambiguity in Permalink #3102

@ominty

Description

@ominty

Link to repo - this includes the following:

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.

index.md or foo.md is content and metadata for the single pages,

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 use the following structure:

.
├── config.toml
├── archetypes
├── content
|   ├── _index.md
|   ├── womo
|   |   ├── index.md
|   |   ├── fahrgestell.md
|   |   ├── aufbau.md
|   |   ├── einrichtung.md
|   |   └── {more pages}.md
|   ├── hund
|   ├── blog
|   └── kontakt
├── static
├── data
├── layouts
└── themes

and this renders to

.
└── public
    ├── index.html
    ├── womo.html
    ├── womo
    |   ├── index.html
    |   ├── fahrgestell.html
    |   ├── aufbau.html
    |   ├── einrichtung.html
    |   └── {more pages}.html
    ├── hund.html
    ├── hund
    ├── blog.html
    ├── blog
    ├── kontakt.html
    └── kontakt

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

Now I use the following code to produce a sidenav within the womo section.

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

It ends up like this:

<li><a href="../womo.html">Einführung</a></li>                   
<li><a href="../womo/fahrgestell.html">Fahrgestell</a></li>            
<li><a href="../womo/aufbau.html">Aufbau</a></li>            
<li><a href="../womo/einrichtung.html">Einrichtung</a></li>

which obviously is wrong since the first line should be like

<li><a href="../womo/index.html">Einführung</a></li>

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

Hugo 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.

That's why I used to rename /section/index.md to something else like /section/intro.md in the snapshots above and everything worked fine

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions