Hugo using filter without categories and tags mess?

Hi there! I need some help with structuring my Hugo website’s content. Currently, I have a directory called /properties/ in my content, which contains multiple pages showcasing properties for sale or rent.

I want to avoid having a URL like example.com/properties and instead handle the categorization within the page’s front matter.

Here’s what I’m aiming for: within the “properties” directory, I would like to categorize properties further, such as by “sale” or “rent.” Additionally, there are sub-categories like “commercial” and “residential.” Within the “residential” category, there are further sub-categories like “home,” “apartment,” “studio,” and so on. Furthermore, I want to include various property details such as square meters, floor number, year of construction, presence of a lift, and more.

I’m wondering if using categories and tags would be a suitable approach to achieve this structure in Hugo, or if there’s another solution you can recommend. Any guidance or alternative ideas would be greatly appreciated!

This may help your problem.

and also please see

Hi @devsr-gt

It doesn’t help because if I have a content directory for example /properties and then I create a taxonomy called properties both will produce a url such as:

directory = example.com/properties
taxonomy = example.com/properties

as you can see in the above example there will be conflicting url which I can change with url management but why do I need to have this mess. can’t I just use categories without creating any separate content and use those categories just to apply filters such as

category > property >> sale/rent
subcategory > property type >> commercial/residential

thanks

You can, but naming a content directory like a taxonomy might not be the best choice.

Hi @chrillek

I realise that but how else can I do this, I want to have 1 directory with all the property listings and I want let users to filter those listings based on if property is for sale or rent, commercial or residential, sqm, floors etc.

How can I do this what else I can use in Hugo as I only see taxonomy which I can use to filter can the front matter be used for filtering?

I can add front matter such as

properties:
  id: 145434
  for: sale
  type: residential
  subtype: apartment
  floor: 2
  sqm: 13

Thanks

First off, I’m not sure if a static site generator is the best possible choice for a website with (presumably) often changing content. Personally, I’d rather think “database-based approach”.

You could, for example, name your directory “listing” instead of “properties”. Organizing things so that different attributes cause the files to be stored in different directories might not be the best choice – what if someone wants to sell but is also open to renting? If a database approach is not for you, putting every offer in its own file under “listing” and adding the relevant attributes like sqm, lift etc. to the front matter might be a sensible way to get it working.

What amount of data are we talking about, anyway?

Hi @chrillek

the content change once in 2-3 days so static site is more than good enough for this

this will create duplicate url for the same property and doesn’t make any sense to me as there are multiple categories so with 10 categories it is going to create 1000 pages for only 100 listings. such as

/properties/sale
/properties/rent
/properties/residential
/properties/apartments

and so on which will make just a few pages in the content directory to generate thousands of duplicated pages

This is not my problem

how can I use the front matter filters on the website as categories are really easy to filter with Hugo

less than 1000 listings.

The main issue is with limitation of Hugo and not knowing what to do for me.

I think it is better and easier to keep 1 directory listing so it will be easier to create new listings via the netlify cms.

I do not find anything else in Hugo that can let me use filter other then the taxonomy.

Thanks

Maybe Hugo is just not the right tool for you or for this task. A thousand listings changing every 2 to 3 days organized in static MD files, although the data is basically relational – that looks like the search for a nail because one has a hammer.

Looking closer might help. The documentation has something on that here

and already the second example here is tailored to your use case

Hi @chrillek

This is making use of categories and tags which is taxonomy. Which creates unwanted url and duplicates of the same listings

this is filtration but my question is how will it work and if front matter or categories which can work without creating additional directories and duplicate pages of the same listing?

Thanks

Read all of it, please. And play around with the stuff to see what happens and how it might work for you. The question of using front matter parameters has been discussed quite thoroughly in the forum already. No point in repeating all that.

Hi @chrillek

do you have any url of the previously discussed such issue? I have not find any

Searching for “range front matter” should give you useful hints.