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

Handle uglyURLs ambiguity in Permalink #3102

Closed
ominty opened this Issue Feb 26, 2017 · 6 comments

Comments

Projects
None yet
2 participants
@ominty
Contributor

ominty commented Feb 26, 2017

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

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Feb 26, 2017

Member

The repo you link to does not look like the site you describe (no motorhome).

Member

bep commented Feb 26, 2017

The repo you link to does not look like the site you describe (no motorhome).

@ominty

This comment has been minimized.

Show comment
Hide comment
@ominty

ominty Feb 26, 2017

Contributor

sorry, but all the site is in german.
motorhome would be "womo"
dogs would be "hund"
contact would be "kontakt"

I hope this will solve this - I translated the excerpts for the convenience of the readers as the support forum is in english. But translate all of the site - I hope this will not be necessary ...

Contributor

ominty commented Feb 26, 2017

sorry, but all the site is in german.
motorhome would be "womo"
dogs would be "hund"
contact would be "kontakt"

I hope this will solve this - I translated the excerpts for the convenience of the readers as the support forum is in english. But translate all of the site - I hope this will not be necessary ...

@ominty

This comment has been minimized.

Show comment
Hide comment
@ominty

ominty Feb 26, 2017

Contributor

I updated the structure above to match the actual repo. Readme.md is also updated.
Sorry for the confusion.

Contributor

ominty commented Feb 26, 2017

I updated the structure above to match the actual repo. Readme.md is also updated.
Sorry for the confusion.

@bep bep changed the title from index.md within section - link renders to wrong place to Handle uglyURLs ambiguity in Permalink Feb 26, 2017

@bep bep added Enhancement and removed NeedsUserFeedback labels Feb 26, 2017

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Feb 26, 2017

Member

OK, I see it now, but I'm not sure how to solve it. Maybe others will.

There is an uglyURLs ambiguity here, but we seem to have gotten it right when we wrote the file to disk, so ...

  • The page starts out with the URL "womo/index.html"
  • The logic to make that ugly "womo/index.html" => "womo.html"
Member

bep commented Feb 26, 2017

OK, I see it now, but I'm not sure how to solve it. Maybe others will.

There is an uglyURLs ambiguity here, but we seem to have gotten it right when we wrote the file to disk, so ...

  • The page starts out with the URL "womo/index.html"
  • The logic to make that ugly "womo/index.html" => "womo.html"
@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Feb 26, 2017

Member

That said, a workaround that should work for you is to put a url override in your womo/index.md:

url = "womo/index.html"
Member

bep commented Feb 26, 2017

That said, a workaround that should work for you is to put a url override in your womo/index.md:

url = "womo/index.html"

@bep bep added Bug and removed Enhancement labels Feb 26, 2017

@ominty

This comment has been minimized.

Show comment
Hide comment
@ominty

ominty Feb 26, 2017

Contributor

Thanks - I did not know about that override - will test it.

update: and it works, the only thing is:
url = "/womo/index.html"

I tested on server and from local storage. Thanks again.

Contributor

ominty commented Feb 26, 2017

Thanks - I did not know about that override - will test it.

update: and it works, the only thing is:
url = "/womo/index.html"

I tested on server and from local storage. Thanks again.

@bep bep referenced this issue Mar 13, 2017

Closed

Add custom output formats #2828

26 of 26 tasks complete

@bep bep added this to the v0.20 milestone Mar 14, 2017

@bep bep self-assigned this Mar 14, 2017

bep added a commit to bep/hugo that referenced this issue Mar 27, 2017

hugolib: Refactor/-work the permalink/target path logic
This is a pretty fundamental change in Hugo, but absolutely needed if we should have any hope of getting "multiple outputs" done.

This commit's goal is to say:

* Every file target path is created by `createTargetPath`, i.e. one function for all.
* That function takes every page and site parameter into account, to avoid fragile string parsing to uglify etc. later on.
* The path creation logic has full test coverage.
* All permalinks, paginator URLs etc. are then built on top of that same logic.

Fixes #1252
Fixes #2110
Closes #2374
Fixes #1885
Fixes #3102
Fixes #3179
Fixes #1641
Fixes #1989

@bep bep closed this in 6bf010f Mar 27, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment