If URL Contains x Then Do Y in Twig / Craft Template? I've got a website that has a resource center, news center and blog where each of those sections has a high quantity of assets that can be filtered by topic / type / date, etc. Additionally, due to the quantity of assets, we're using pagination to spread the assets across multiple pages.

All of the filtering and pagination creates a variety of worthless but currently crawlable URLs that we'd like to hide from the search engines.

I'm attempting to deploy the meta name="robots" content="noindex, follow" tag to all of the paginated / filtered URLs while keeping the overview pages indexed. It seems that the most logical way to do that is based on a consistent URL string that appears in both pagination and filtering instances.

How can I add a rule within my template that will insert the meta tag based on whether or not a string exists in the current URL appearing in a user's browser?

Any help would be much appreciated. Thanks!
If the string you're looking for is part of the URI segment, then something like:

{% if (craft.request.getSegment(3) == 'mySpecialKey') %}
    &lt;meta name="robots" content="noindex, follow"&gt;
{% endif %}


(Adjusting the 3 for whichever part of the segment it's actually in.

Or if it's part of the querystring, then use craft.request.getParam('mySpecialKey').