Answers.Body: <p>You can't automatically expand variables inside strings in Twig as you would normally do in PHP.</p>
  
  <p>Instead, you have to concatenate your strings.</p>
  
  <pre><code>{% set seo = craft.seo.custom('Discount codes and vouchers for ' ~ query, 'You searched for ' ~ query ~ '. Check out the latest live ' ~ query ~ ' discount codes &amp; voucher codes for ' ~ now|date('m') ~ ' ' ~ now|date('Y') ~ ' only at Vouchertoday.uk') %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-28T16:43:17.433Z
Answers.Text: Thanks for the answer, but it seems to still not be setting the object?
Answers.UserDisplayName: JMKelley
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-01T14:18:47.047Z
Answers.Text: Try {% do craft.seo.custom(all the stuffs) %} instead of setting it to a local variable. NB: I haven't used this exact plugin myself, so I'm just trying to apply logic to it :)
Answers.UserDisplayName: Fuglsetrampen
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-04T12:14:11.080Z
Answers.Text: This throws an error.
Answers.UserDisplayName: JMKelley
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-04T12:14:22.030Z
Answers.Text: "Unexpected token "operator" of value "=" ("end of statement block" expected)."
Answers.UserDisplayName: JMKelley
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-05T07:53:56.250Z
Answers.Text: Hmm, could you post the entire line? There's no '=' in my example, so I need to see where else it could be going wrong
Answers.UserDisplayName: Fuglsetrampen
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-19T09:02:16.907Z
Answers.LastActivityDate: 2018-02-20T00:41:53.847Z
Answers.LastEditDate: 2018-02-20T00:41:53.847Z
Answers.UserDisplayName: Fuglsetrampen
Body: <p>I'm currently using <a href="https://github.com/ethercreative/seo" rel="nofollow noreferrer">SEO by EtherCreative</a> on Craft 2, one of my pages needs a custom title and description injected into it like this on the docs:</p>
  
  <blockquote>
    <p>In some cases, you will not have access to an SEO field, but will want
    to set the page title &amp; description. You can do this by creating a
    custom SEO object using the function below:</p>
  </blockquote>
  
  <pre><code>craft.seo.custom('The Page Title', 'The page description', $includeDefaultTitleSuffix)
  </code></pre>
  
  <p>Mine seems to be throwing errors or not doing anything like so:</p>
  
  <pre><code>  {% set seo = craft.seo.custom('Discount codes and vouchers for {{ query }}', 'You searched for {{ query }}. Check out the latest live {{ query }} discount codes &amp; voucher codes for {{ "now"|date("m") }} {{ "now"|date("Y") }} only at Vouchertoday.uk') %}
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-02-17T13:19:19.437Z
Comments.Text: Maybe you could explain the problem a little bit better? What doesn't work? What errors do you receive?
Comments.UserDisplayName: Robin Schambach
Tags: <plugins><seo><plugin-seo>
Title: Setting a Plugin Object
ThreadText: # Setting a Plugin Object
  
  (Asked by: username_0 on 2018-02-17)
  
  I'm currently using [SEO by EtherCreative](https://github.com/ethercreative/seo) on Craft 2, one of my pages needs a custom title and description injected into it like this on the docs:
  
  > In some cases, you will not have access to an SEO field, but will want
  > to set the page title & description. You can do this by creating a
  > custom SEO object using the function below:
  
  ```
  craft.seo.custom('The Page Title', 'The page description', $includeDefaultTitleSuffix)
  
  ```
  
  Mine seems to be throwing errors or not doing anything like so:
  
  ```
    {% set seo = craft.seo.custom('Discount codes and vouchers for {{ query }}', 'You searched for {{ query }}. Check out the latest live {{ query }} discount codes & voucher codes for {{ "now"|date("m") }} {{ "now"|date("Y") }} only at Vouchertoday.uk') %}
  
  ```
  
  **Tags:** plugins, seo, plugin-seo
  
  > **Comments:**
  > **username_1**: Maybe you could explain the problem a little bit better? What doesn't work? What errors do you receive?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2018-02-19. Score: 1
  
  You can't automatically expand variables inside strings in Twig as you would normally do in PHP.
  
  Instead, you have to concatenate your strings.
  
  ```
  {% set seo = craft.seo.custom('Discount codes and vouchers for ' ~ query, 'You searched for ' ~ query ~ '. Check out the latest live ' ~ query ~ ' discount codes & voucher codes for ' ~ now|date('m') ~ ' ' ~ now|date('Y') ~ ' only at Vouchertoday.uk') %}
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks for the answer, but it seems to still not be setting the object?  
  > **username_2**: Try {% do craft.seo.custom(all the stuffs) %} instead of setting it to a local variable. NB: I haven't used this exact plugin myself, so I'm just trying to apply logic to it :)  
  > **username_0**: This throws an error.  
  > **username_0**: "Unexpected token "operator" of value "=" ("end of statement block" expected)."  
  > **username_2**: Hmm, could you post the entire line? There's no '=' in my example, so I need to see where else it could be going wrong  
  
  ---
  
  