Can someone explain to me the difference between {exp:stash:get name="foo"}, {exp:stash:foo} and {stash:foo}?

I'm relatively new to ExpressionEngine, and after discovering Stash, I'm amazed at how powerful of a tool it can be, when used properly.

In reading the documentation and support forums, I've seen reference to all three tags that, I believe, all serve to retrieve a variable. However when I try them out, I sometimes find that I get slightly different results when I interchange them.

According to the documentation, {exp:stash:get name="foo"}, {exp:stash:foo} are the same thing, and I've only seen passing references to the third {stash:foo}. Even if they all serve the same purpose, do each have their own particular uses that make them differ from the others?

2 Answers 2


{exp:stash:get name="foo"} is a module tag. When the template parser encounters it, it calls the get() method of the 'stash' module class, which returns the value of foo. If foo doesn't exist, an empty value is returned, unless the default="" parameter has been set.

{exp:stash:foo} is a shorter syntax version of the above tag, for convenience.

{stash:foo} used on its own (not as a tag pair) is a placeholder for a native Stash variable, similar to an ExpressionEngine snippet. When the parser encounters it, it looks up the value of foo in a special array that Stash uses to store all variables that have been created previously in the parse order. The value it finds then replaces the placeholder. If it doesn't find a value the placeholder is left in the template.

Which you use depends on parse order. Inside Stash embeds and any blocks of code parsed by Stash, placeholders in the form {stash:variable} are parsed before ExpressionEngine tags, but after snippets. That makes them useful for passing values into tag parameters which are parsed later.

Note that you can also set a ExpressionEngine snippet value by using type="snippet"

{exp:stash:set name="foo" type="snippet"}value{/exp:stash:set}

This can then be accessed inside EE or Stash embeds and any blocks of code parsed by Stash in the form:



{stash:foo} can be used when using the set pair tag, so for example


Would set 2 stash variables, foo and bar respectively. I believe the benefit here is that there's less method calls than the {exp:stash:set name=""} alternative (although note this is an assumption).

You can also use {stash:foo} when within a setting (whether it's normal or lists) pair tag to 'GET'

  • Yes, that's in the documentation, but in the GET context, is there a difference?
    – nageeb
    Commented Mar 11, 2014 at 8:04
  • What I mean by this is, I believe it's only valid in the SET context and doesn't work in GET.
    – Mutual
    Commented Mar 11, 2014 at 8:06
  • Not true. I was having a similar issue to this support question: devot-ee.com/add-ons/support/stash/viewthread/9011#30659 and the answer helped me sort my problems out, which is what prompted me to ask the above question in the first place :)
    – nageeb
    Commented Mar 11, 2014 at 8:11
  • Sorry I understand what you mean now. I've updated my answer with my understanding, but I'm not 100% on this one. I'll keep an eye on the thread for any other answers.
    – Mutual
    Commented Mar 11, 2014 at 8:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.