I am trying to pass a member's firstName and lastName to the title on a member profile page. I am using segment 2 to capture the username. This works well in the for loop in the block:

{% set thePartner = craft.users.username( craft.request.getSegment(2) ) %}
{% for partner in thePartner %}
First Name and Last Name: {{ partner.firstName}} {{ partner.lastName }}
{% endfor %)

Outside the block, where I set the <title>, it doesn't work. Essentially, I would like to set the full name and use it in the title, like:

{% set fullname = partner.firstName ~ ' ' ~ partner.lastName %}

with something like the following in _layout:

<title>{{ fullname }} | {{ siteUrl }} </title>

How can I pass the full name through?

  • As you probably don't have only profile pages on your site, remember to only render fullname into the <title> of your _layout template if the var is actually set: {{ fullname ? fullname ~ '|' }}!
    – carlcs
    Aug 2, 2014 at 17:00

1 Answer 1


Since you're just expecting one, you should only look for one. Then you don't have to use a for loop. Plus, fullName is already an attribute of user models. So you can do this for the title:

{% set thePartner = craft.users.username( craft.request.getSegment(2) ).first() %}
<title>{{ thePartner.fullName }} | {{ siteUrl }} </title>

If you're still having trouble, it may be with what segments you are pulling from the URL.


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.