-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Comments
To be specific, the links to posts are in the uglyURL form - i.e. the link does end in _.html and works correctly. 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
Likewise the tags link (e.g. for tag linux)
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 |
I've just written a little Python 3 program to patch the files in /public so the generated tag and category pages work correctly: |
I just tested this, and 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) |
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. |
@GiovanniMoretti I looked at your site. The links are created by the template:
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. |
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):
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
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. |
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. |
Can templates even check whether uglyURLs is set to true? Alternatively, what do you think about exposing the |
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 If this is a feature request, and you feel that it is still relevant and valuable, please tell us why. |
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
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. |
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.
The text was updated successfully, but these errors were encountered: