Skip to content
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 · 7 comments
Closed

Handle uglyURLs ambiguity in Permalink #3102

ominty opened this issue Feb 26, 2017 · 7 comments
Assignees
Milestone

Comments

@ominty
Copy link
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
Copy link
Member

bep commented Feb 26, 2017

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

@ominty
Copy link
Contributor Author

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
Copy link
Contributor Author

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 index.md within section - link renders to wrong place Handle uglyURLs ambiguity in Permalink Feb 26, 2017
@bep
Copy link
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
Copy link
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
Copy link
Contributor Author

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 mentioned this issue Mar 13, 2017
26 tasks
@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
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 gohugoio#1252
Fixes gohugoio#2110
Closes gohugoio#2374
Fixes gohugoio#1885
Fixes gohugoio#3102
Fixes gohugoio#3179
Fixes gohugoio#1641
Fixes gohugoio#1989
@bep bep closed this as completed in 6bf010f Mar 27, 2017
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants