I'm having two separate no_results problems with Stash.

First, if I visit a page that doesn't have a corresponding last segment using the code below, the page displays stuff like {2e1acf078c376a119e542c46883a119f33292409} and nothing else:

{stash:embed name="layouts:global"}

    {if no_results}{redirect="404"}{/if}

    {exp:stash:set name="st_content" type="snippet"}


Then in another template, the switchee_no_results doesn't redirect to the 404 template, it just displays a page with a blank content area. I've also tried just plain no_results and also settings a prefix parameter on the get_list tag.

{stash:embed name="layouts:global"}


        {if segment_2=="detail"}url_title="{last_segment}"{/if}





{exp:stash:set name="st_content" type="snippet"}

    {exp:switchee variable="{segment_2}" parse="inward"}

        {!-- Landing page --}
        {case value=""} … {/case}

        {!-- Detail page --}
        {case value="detail"}


        {if switchee_no_results}{redirect="404"}{/if}






Anyone know why that might be?

1 Answer 1


The short answer is to use a full template_group/template path to your 404, e.g.


I explained the reason why here: Strange Stash & redirect issue


Since this post was made I have added a new tag {exp:stash:not_found} to help with situations where the no_results condiotonals are nested inside other tags:


Note that the best place to use {if no_results}... is on the tag that you are trying to capture data from.

  • That solves the first part of the question (partly), but not the second in the switchee_no_results. And I say partly because when using site/404, you actually get redirected to that URL rather than the 404 template displaying at the broken URL which is the behaviour exhibited when just specifying redirect="404" and which I believe is necessary for the URL to be recorded as a 404 rather than a 301 in the search engines.
    – Tyssen
    Dec 4, 2013 at 20:45
  • I'm adding a comment here so i can watch for the solution because I'm having a similar issue. If no results tag pair is resulting in a blank page body in the template rather that showing the actual 404 page and I'm struggling to determine why. I have require_entry="yes" and url_title="{last_segment}" along with dynamic="no" and {if no_results}{redirect_404}{/if} tag pair inside my stashed entries loop but I still get an empty template rather than getting redirected to my 404 template. Nov 12, 2015 at 17:10
  • @jean See updated post above Nov 12, 2015 at 19:21
  • I'm still having no luck with it, Mark. I can put whatever I want into the URL and as long as there is a matching template group is segment1 I get a page served. Nov 13, 2015 at 14:48

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .