How to filter content based on url?

I am importing all the javascript files in script.html and using it as an include in a layout, but I don’t want to use all the js file. I want to use different js files based on url.

Here’s what the layout file looks like:

{% include nav.html %}

{{ content }}

{% include script.html %}

How can i do that?

Add Liquid logic to your scripts.html include.

{% if page.url == ‘foo/bar.html’ %}
  scripts
{% elsif page.url == ‘some/other-page.html’ %}
  other scripts
{% else %}
  even more scripts
{% endif %}