Url passed parameter

Hi guys,

I have this url “http://localhost:4000/neviera.html?mname=Grotta%20della%20neve

I would like use the content of the parameter name inside the page in such this way
{% for member in site.data.Neviere_di_Sicilia %}
{% if member.name == name %}
do your job…
{% endif %}
{% endfor %}

But it doesn’t work

What i have to do so that it works?

Thanks in advance

You have to understand that Liquid runs while building and JavaScript while rendering.

I know how to get the variable in php (for instance), but I didn’t understand how to do the same in Jekyll. Your suggestion unfortunately doesn’t help me. Anyway thanks the same for your help, You tried :slight_smile:

Jekyll doesn’t work like PHP. Jekyll sites are built into static HTML. You simply can’t pass URL parameters to Liquid templates as there is no server to process it.

You can use JavaScript to process parameters and modify the HTML in the browser. But if you need to do that work server-side, use PHP (or another server-side language).

1 Like

I have tried this and it worked fine . Maybe this will help you as welll.

  1. Assign first
  2. Then the for loop
  3. Then checking the condition

{% assign main-category = site.main-category %}
{% for main-category in site.main-category %}
{% if main-category.tags contains 'name ’ %}
do your job…
{% endif %}
{% endfor %}

I use this for finding 3 posts that contain the tag (page.tag) of the page you are on.

{% assign siteposts = site.posts | where_exp: "item", "item.tags contains page.tag" %}
{% for item in siteposts limit:3 %}
  do your job…
{% endfor %}

This does not use the URL though… but might still be what you are after.