<p>Ended up changing the title to a block within my layout template and doing thus:</p>

<pre><code>{% extends "_layout" %}
{% set query = craft.request.getParam('q') %}
{% block title %}Search results for: {{query}}{% endblock %}
</code></pre>

CC BY-SA 3.0
2014-12-24T12:06:58.513Z
2014-12-24T12:06:58.513Z
Steven Grant
<p>You should be able to use:</p>

<pre><code>{% set title = "Search results for: " ~ query %}
</code></pre>

CC BY-SA 3.0
2014-12-24T16:25:10.787Z
2014-12-24T16:25:10.787Z
Steve Abraham
<p>I wish to show the search query inside the page template but my logic seems to be off and just shows {{ query }} as a string.</p>

<p>What's the best way to achieve this?</p>

<pre><code>{% extends "_layout" %}
{% set query = craft.request.getParam('q') %}
{% set title = "Search results for: {{ query }}" %}
</code></pre>

<templating><variable>
passing the search query into html title tag
# passing the search query into html title tag

(Asked by: username_0 on 2014-12-24)

I wish to show the search query inside the page template but my logic seems to be off and just shows {{ query }} as a string.
What's the best way to achieve this?
{% extends "_layout" %}
{% set query = craft.request.getParam('q') %}
{% set title = "Search results for: {{ query }}" %}

**Tags:** templating, variable

---

## 2 answers

### Answer by username_1 on 2014-12-24. Score: 5 | Accepted answer

You should be able to use:
{% set title = "Search results for: " ~ query %}


---

### Answer by username_0 on 2014-12-24. Score: 1

Ended up changing the title to a block within my layout template and doing thus:
{% extends "_layout" %}
{% set query = craft.request.getParam('q') %}
{% block title %}Search results for: {{query}}{% endblock %}


---

