Re: 404 page - if statement on the URL

How can I create different 404 pages based on URL?

premmels
Excursionist
19 0 4

Hi there,

I want to have a few different 404 pages, depending on where the customer went wrong and identify the cases via the URL.

Let's say someone accesses a page myurl.com/234234234234324/orders/ I want to catch this case in an if statement

{% if handle contains '/orders' %}
	Test
{% else %}
<div class="EmptyState">
  <div class="Container">
    <h3 class="EmptyState__Title Heading u-h5">{{ '404.general.title' | t }}</h3>
    <p class="EmptyState__Description Text--subdued">{{ '404.general.content' | t }}</p>
    <a href="{{ routes.root_url }}" class="EmptyState__Action Button Button--primary">{{ '404.general.button' | t }}</a>
  </div>
</div>
{% endif %}

 

Now accessing the URL myurl.com/234234234234324/orders/ should give me back "Test", which it doesn't.

Maybe the order pages don't have a handle?

How else could I access the URL in this case?

Thanks,
Patrick

Reply 1 (1)

premmels
Excursionist
19 0 4

Any suggestions?