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

Widget page: filter by tag/category breaks down if blank space #1388

Closed
Bertbk opened this issue Oct 14, 2019 · 0 comments
Closed

Widget page: filter by tag/category breaks down if blank space #1388

Bertbk opened this issue Oct 14, 2019 · 0 comments
Labels
Milestone

Comments

@Bertbk
Copy link
Contributor

Bertbk commented Oct 14, 2019

Problem

The filter by tag (or category) of the pages widget does not work if the tag (or category) contains a blank space. For example:

# content/talk/mytalk.index.md 
tags = ["Great tag"]
# content/home/talks.md 
[content.filters]
    tag = "Great tag"

This is due to the fact that the query is made on an url in layout/widgets/partials/pages.html:

{{ if $st.Params.content.filters.category }}
  {{ $archive_page = site.GetPage (printf "categories/%s" $st.Params.content.filters.category) }}
  {{ $query = $query | intersect $archive_page.Pages }}
{{ end }}

Hugo will look at webiste.com/tags/Great tag instead of its url version webiste.com/tags/great-tag.

Possible fix

I suggest to add urlize (3 times: tags, categories, and publication_types):

{{ if $st.Params.content.filters.category }}
  {{ $archive_page = site.GetPage (urlize (printf "categories/%s" $st.Params.content.filters.category)) }}
  {{ $query = $query | intersect $archive_page.Pages }}
{{ end }}

Enhancement?

By the way, it might better to allow multiple tags (or categories) as a filter instead of only one?

@gcushen gcushen added the bug label Oct 15, 2019
@gcushen gcushen added this to the v4.6 milestone Oct 15, 2019
SJamieson pushed a commit to SJamieson/hugo-academic that referenced this issue Jan 22, 2020
YoungWilliamZ pushed a commit to YoungWilliamZ/hugo-academic that referenced this issue Jul 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants