If this topic is challenging to discuss, or if there is already an existing solution that I haven’t yet discovered, it appears that either it isn’t of interest or it’s too complex to address.
Any comments or feedback would be greatly appreciated.
I don’t think it is possible to automatically create category combinations. What you could do is to create a section and in that section you define the URL and the combined categories via frontmatter.
For instance:
/combinations/ - the section (you will need layouts/combinations/single.html, and other layout files probably)
/combinations/black-cat/index.md
In /combinations/black-cat/index.md you have the following frontmatter:
combinations:
- color: black
- animal: cat
Then in layouts/combinations/single.html you would use those frontmatter tags to range through a page collection with those two taxonomies set.
You will have to create one index.md per combination, which might be a hassle.
Another solution might be to show all posts and implement some form of dynamic loading of posts via javascript that read options from the URL. like /combinations.html?color=black&animal=cat. For that you could create a custom post type that puts all your content files as JSON somewhere and then load dynamically.
Both ways need some to much work to create the solution.
This is what i currently do but it is not manageable
# For example the totals i am working with are as follows
colors: 550
Birds: 11,000+
i get a combination of 11,000 birds x 550 colors = 6,050,000 combinations. at this level it is almost imposible for me to remember which category combinations are already generated. But i think if hugo can do it automatically that is goign to way more usefull then the manual labour. And i think this will also extend the current use cases of hugo.
I am not sure if it is possible already in hugo as it will be stupid to generate manually all these pages if it currently possible in hugo.
That’s possible by using ExecuteAsTemplate or FromString, you’re able to create any custom pages or resources. But as you said, there will be a large number of the combinations/pages, I’m afriad it will increase the build time heavily, as this point, I’d prefer do it in JS that create an index JSON file, and fetch and filter the results by combination.
this is the second method i try, as i use js and load 12 cards from json and have the load more button. the problem is with the design while in hugo layout i have made a very complex card which automatically place logo watermark add ribbon etc.
But when using json i loose all this as the json fiel is being generated directly from the page front matter. if there was an easier version where i can generate the json file after the image and card processing such as using
{{ $resultsPerPage := 18 }} <!-- Set the number of results per page -->
{{ $allPages := where .Site.RegularPages "Section" "birds" }}
{{ $sortedPages := sort $allPages ".Params.title" "desc" }}
{{ $paginator := .Paginate $sortedPages $resultsPerPage }}
{{ $currentPageNumber := $paginator.PageNumber }}
{{ range $paginator.Pages }}
{{ partial "components/card.html" . }}
{{ end }}
So for example use the above layout and produce json data instead of html data.
IS this possible? I would like to get the card layout from the partial/components/card.html and get the remaining data from the front matter and generate the json file.
Yes, but I mean single filter page for all combinations, you can gather all neccessary data via template and put it in JSON (ExecuteAsTemplate or FromString, or custom output), and then using JS fetch the JSON and render the data on HTML page.
how can i use the $image736 which is generated in the html layout and use it in the json instead of the current "coverImage" .coverImage which is basically getting url from the page front matter?
since the image in the .Params.coverImage is not processed and this image is not available and json simply produce not found errors.
I currently have around 16,000 images with complex filters, overlaid agent images, contact details, and I’m resizing them. I’m also converting them into different formats like webp. The issue is that it takes approximately 18 minutes for Hugo to build the website.
I’m wondering if I can use the images that are already created in the card layout for JSON, even though I’m not concerned about the local build time. The problem is that Hugo’s build time is consuming a significant portion of my allocated build minutes on Netlify.
can i tell hugo that this image i also want to use in my json layout and then in the json layout simply add "coverImage" .$savedImageFromCardLayout