Rather than loop through my collection ‘products’ then use a condition to check if it’s the specific page I want… is there a way to to target a specific page?
I would say there is a more appropriate way to get a single page on Jekyll site.
Use the link tag. Pass it the full path to a page, not just the filename. So it is accurate.
If the path is invalid because you made a typo or the page is renamed or moved, you’ll find out when you run Jekyll serve or build. Whereas using where means you might get 0, 1, or even more pages and if you get zero then you’ll deploy a page which is missing section because it could not find the page it was expecting.
Say for an HTML a tag, here are examples
href="{% link index.md %}"
href="{% link team/joe.md %}"
href="{% link _products/appliances/coffee-machine.md %}"
Note that the path is relative to repo root, regardless of the current page.
And setup in config adds products (no underscore) under collections variable.
Then access a product pages with
site.pages # all pages. Including posts, plain pages and collections
site.products # all pages in the products collection
site.collections # includes multiple collections
I have a simple collection demo here as languages. I iterate through pages in the collection.