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

Taxonomies ignoring uglyurl=true #1989

Closed
sidewinder12s opened this Issue Mar 18, 2016 · 9 comments

Comments

Projects
None yet
4 participants
@sidewinder12s

sidewinder12s commented Mar 18, 2016

Not sure if this is intended but when uglyurls is set to true the generated taxonomy pages do not have uglyurls, they still use just folders instead of making all the links pointed directly to files.

@GiovanniMoretti

This comment has been minimized.

Show comment
Hide comment
@GiovanniMoretti

GiovanniMoretti Apr 12, 2016

To be specific, the links to posts are in the uglyURL form - i.e. the link does end in _.html and works correctly.
Unfortunately the links to categories and tags are still in the form as if uglyurl=false - i.e. they point to directories, not to HTML files and don't work.

For category and tag items, the folder being pointed at (e.g. http://localhost:1313/categories/general/) contains an index.xml and a page subdirectory, but no HTML file so doesn't render anything, leaving the user staring at a blank page.

It turns out that at individual category and tag pages are being generated correctly, but the links are wrong.

e.g. the generated link to the general category is

       http://localhost:1313/categories/general/           But it should be 
       http://localhost:1313/categories/general.html

Likewise the tags link (e.g. for tag linux)

      http://localhost:1313/tags/linux/                    And this should be
      http://localhost:1313/tags/linux.html

Using uglyurls=true is important as it keeps the rendered HTML files in their original directories (i.e. in same relative location next to images etc).

If uglyurls=false, then the rendered HTML file is moved into its own directory breaking all the relative links that it contains to images, files to download ....

The files in /content are generated by Emacs Orgmode's "Export to HTML" and look fine when rendered by Hugo, and the orgmode files are in the own directories with related images and other files i really don't want to shift, so it'd be great if the links to categories and tags when uglyurls=false option was fixed.

Then I get the power of orgmode with the benefits of Hugo :-)

Many thanks - Giovanni

GiovanniMoretti commented Apr 12, 2016

To be specific, the links to posts are in the uglyURL form - i.e. the link does end in _.html and works correctly.
Unfortunately the links to categories and tags are still in the form as if uglyurl=false - i.e. they point to directories, not to HTML files and don't work.

For category and tag items, the folder being pointed at (e.g. http://localhost:1313/categories/general/) contains an index.xml and a page subdirectory, but no HTML file so doesn't render anything, leaving the user staring at a blank page.

It turns out that at individual category and tag pages are being generated correctly, but the links are wrong.

e.g. the generated link to the general category is

       http://localhost:1313/categories/general/           But it should be 
       http://localhost:1313/categories/general.html

Likewise the tags link (e.g. for tag linux)

      http://localhost:1313/tags/linux/                    And this should be
      http://localhost:1313/tags/linux.html

Using uglyurls=true is important as it keeps the rendered HTML files in their original directories (i.e. in same relative location next to images etc).

If uglyurls=false, then the rendered HTML file is moved into its own directory breaking all the relative links that it contains to images, files to download ....

The files in /content are generated by Emacs Orgmode's "Export to HTML" and look fine when rendered by Hugo, and the orgmode files are in the own directories with related images and other files i really don't want to shift, so it'd be great if the links to categories and tags when uglyurls=false option was fixed.

Then I get the power of orgmode with the benefits of Hugo :-)

Many thanks - Giovanni

@GiovanniMoretti

This comment has been minimized.

Show comment
Hide comment
@GiovanniMoretti

GiovanniMoretti Apr 20, 2016

I've just written a little Python 3 program to patch the files in /public so the generated tag and category pages work correctly:
https://gist.github.com/GiovanniMoretti/8c874652689960c9c11d81952c0ecbd6

GiovanniMoretti commented Apr 20, 2016

I've just written a little Python 3 program to patch the files in /public so the generated tag and category pages work correctly:
https://gist.github.com/GiovanniMoretti/8c874652689960c9c11d81952c0ecbd6

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Apr 20, 2016

Member

I just tested this, and uglyurls=true works fine for taxonomies.

Not sure what you mean by "making all the links pointed directly to files".

Can you provide a concrete example of a wrong link produced by Hugo?

(with emphasis on Hugo -- because I suspect many links to taxonomy pages are created manually)

Member

bep commented Apr 20, 2016

I just tested this, and uglyurls=true works fine for taxonomies.

Not sure what you mean by "making all the links pointed directly to files".

Can you provide a concrete example of a wrong link produced by Hugo?

(with emphasis on Hugo -- because I suspect many links to taxonomy pages are created manually)

@GiovanniMoretti

This comment has been minimized.

Show comment
Hide comment
@GiovanniMoretti

GiovanniMoretti Apr 20, 2016

Thanks for checking. I've attached a file that has the examples/blog subdirectory from the Github source for Hugo, and I've added some more posts to the /content/post directory, so there are a reasonable number of categories and tags.

What you see in the public directory is the output of "hugo" - I'm using Hugo v0.15 via Homebrew on a Macbook.

If you run 'hugo server' and have a look at the first post - it's in the General category (and so are lots of other pages) but the link is to the general directory which doesn't contain a HTML file so the displayed page is empty.

Another example, from the home page, scroll down to the post starting with VP2E offcentre. It's in the "Radio" category and has the tag "Antennas" (as do several other pages). Neither of the links on the right hand side of the page show the entries for the category or tag respectively.

Hopefully this concrete example helps. The only change to blog example was add the additional posts, and to add uglyurls = true to the config file.
uglyURLtest.zip

GiovanniMoretti commented Apr 20, 2016

Thanks for checking. I've attached a file that has the examples/blog subdirectory from the Github source for Hugo, and I've added some more posts to the /content/post directory, so there are a reasonable number of categories and tags.

What you see in the public directory is the output of "hugo" - I'm using Hugo v0.15 via Homebrew on a Macbook.

If you run 'hugo server' and have a look at the first post - it's in the General category (and so are lots of other pages) but the link is to the general directory which doesn't contain a HTML file so the displayed page is empty.

Another example, from the home page, scroll down to the post starting with VP2E offcentre. It's in the "Radio" category and has the tag "Antennas" (as do several other pages). Neither of the links on the right hand side of the page show the entries for the category or tag respectively.

Hopefully this concrete example helps. The only change to blog example was add the additional posts, and to add uglyurls = true to the config file.
uglyURLtest.zip

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Apr 20, 2016

Member

@GiovanniMoretti I looked at your site. The links are created by the template:

 <li><a href="/categories/{{ . | urlize }}">{{ . }}</a></li>

And the template is created by you or the theme author. I fail to see how Hugo could have fixed this one.

If noone is able to provide an example where Hugo is "doing the wrong thing", I'm gonna close this.

Member

bep commented Apr 20, 2016

@GiovanniMoretti I looked at your site. The links are created by the template:

 <li><a href="/categories/{{ . | urlize }}">{{ . }}</a></li>

And the template is created by you or the theme author. I fail to see how Hugo could have fixed this one.

If noone is able to provide an example where Hugo is "doing the wrong thing", I'm gonna close this.

@GiovanniMoretti

This comment has been minimized.

Show comment
Hide comment
@GiovanniMoretti

GiovanniMoretti Apr 20, 2016

It's not my template. It's the closest to a "canonical example" we can get, (the blog example from Hugo's source), given that Hugo doesn't supply a known correct sample theme/template.

Following your lead above, I've modified the template in layouts/post/single so it now gives the correct URL (by adding .html to the end of the link):

            {{ range .Params.categories }}
                <li><a href="/categories/{{ . | urlize }}.html">{{ . }}</a></li>
            {{ end }}

And both tags and categories now work. Thank you - I now understand what's going on.

I think this points to out an underlying problem, as most if not all of the themes I tried from the Hugo Theme gallery behaved in the same way, so either

  1. there needs to be a way for Hugo to generate the URL that includes the .html (or not) for the taxonomies, OR
  2. theme authors should be encouraged to specify which setting of uglyurl their theme is designed for.

My modification of adding .html explicitly to the layout means it won't work for uglyurls=false.

Is my modification to the layout what you were expecting or is there a more elegant way to make the category and tags links in a layout work correctly when uglyurls=true and and when uglyurls=false?

Apologies if this blindingly obvious to you but I'm completely new to both Hugo and the templating language.

GiovanniMoretti commented Apr 20, 2016

It's not my template. It's the closest to a "canonical example" we can get, (the blog example from Hugo's source), given that Hugo doesn't supply a known correct sample theme/template.

Following your lead above, I've modified the template in layouts/post/single so it now gives the correct URL (by adding .html to the end of the link):

            {{ range .Params.categories }}
                <li><a href="/categories/{{ . | urlize }}.html">{{ . }}</a></li>
            {{ end }}

And both tags and categories now work. Thank you - I now understand what's going on.

I think this points to out an underlying problem, as most if not all of the themes I tried from the Hugo Theme gallery behaved in the same way, so either

  1. there needs to be a way for Hugo to generate the URL that includes the .html (or not) for the taxonomies, OR
  2. theme authors should be encouraged to specify which setting of uglyurl their theme is designed for.

My modification of adding .html explicitly to the layout means it won't work for uglyurls=false.

Is my modification to the layout what you were expecting or is there a more elegant way to make the category and tags links in a layout work correctly when uglyurls=true and and when uglyurls=false?

Apologies if this blindingly obvious to you but I'm completely new to both Hugo and the templating language.

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Apr 20, 2016

Member

Is my modification to the layout what you were expecting or is there a more elegant way to make the category and tags links in a layout work correctly when uglyurls=true and and when uglyurls=false?

Currently no. I'll keep this open. This will be much easier once ...

https://discuss.gohugo.io/t/node-improvements/1593

... is done.

But currently I guess uglyURLs are for people that is in full control of their templates.

Member

bep commented Apr 20, 2016

Is my modification to the layout what you were expecting or is there a more elegant way to make the category and tags links in a layout work correctly when uglyurls=true and and when uglyurls=false?

Currently no. I'll keep this open. This will be much easier once ...

https://discuss.gohugo.io/t/node-improvements/1593

... is done.

But currently I guess uglyURLs are for people that is in full control of their templates.

@mgedmin

This comment has been minimized.

Show comment
Hide comment
@mgedmin

mgedmin May 31, 2016

Can templates even check whether uglyURLs is set to true?

Alternatively, what do you think about exposing the URLizeAndPrep function to the templates?

mgedmin commented May 31, 2016

Can templates even check whether uglyURLs is set to true?

Alternatively, what do you think about exposing the URLizeAndPrep function to the templates?

osgav added a commit to osgav/osgav-blog that referenced this issue Sep 30, 2016

@bep bep added the Stale label Feb 28, 2017

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Mar 1, 2017

Member

Note/Update: This issue is marked as stale, and I may have said something earlier about "opening a thread on the discussion forum". Please don't.

If this is a bug and you can still reproduce this error on the latest release or the master branch, please reply with all of the information you have about it in order to keep the issue open.

If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.

Member

bep commented Mar 1, 2017

Note/Update: This issue is marked as stale, and I may have said something earlier about "opening a thread on the discussion forum". Please don't.

If this is a bug and you can still reproduce this error on the latest release or the master branch, please reply with all of the information you have about it in order to keep the issue open.

If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.

@bep bep removed the Stale label Mar 13, 2017

@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

heavywatal added a commit to heavywatal/hugo-theme-nonblog that referenced this issue Jul 24, 2017

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