I have a view that has a generic title, but uses contextual filters to show the data. I would like to contextually update the title, but am not seeing a solution to this. Is this possible?

Page URL: /person/jon-doe/roster

Page Title: Jon Doe (based on %2)

2 Answers 2


Since you're using Views and the user name. All you need to do is:

  1. Add a Contextual Filter, User: Name
  2. Under it's settings pane, under WHEN THE FILTER VALUE IS IN THE URL OR A DEFAULT IS PROVIDED, check Override title
  3. Then just input %2

So now /person/jon-doe/roster would display as jon-doe as the page title.

If you would want the user's normal name like Jon Doe, then you could follow Immanuel Paul's answer because you aren't basing the page title literally from the URL.

  • boy am I loosing it... I already have that all setup just needed to check the box. Thanks! Commented Apr 7, 2015 at 17:41
  • You're welcome! Glad it's all working for you! Commented Apr 8, 2015 at 1:32
  • Still works in Drupal 8 :) Commented Jul 1, 2020 at 17:51

You can set the Title based on the URL using the drupal function drupal_set_title

in any of the Template preprocess functions such as template_preprocess_views_view or template_preprocess_page

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.