I am working on my SEO and I am getting a duplicate title in Craft. I want to make a custom title using the URI segment in using PHP.

  • Can you give an example, using a URI and then the Title you would like to see?
    – Roi Agneta
    Feb 14, 2019 at 2:43

1 Answer 1


You can use something like this in your main layout template. You'll need to add a filter after "segments" to get the URI segment you want, e.g.: |first or |last, and you'll also need to |replace any hyphens and then |capitalize the first letter of the result.

{% set myUri = craft.app.request.segments %}

<title>{{ myUri }}</title>

For more on segments: https://docs.craftcms.com/v3/changes-in-craft-3.html#template-functions

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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