<p>There are two ways you can set that up, depending on whether you want Brand entries to have a similar URI format (just without the 3rd segment), e.g. <code>category/brand</code>.</p>

<p>Assuming you do, edit your Brands section, and give it the following Entry URI Format:</p>

<ul>
<li><p>Craft 2:</p>

<pre><code>{category.first().slug}/{slug}
</code></pre></li>
<li><p>Craft 3:</p>

<pre><code>{category.one().slug}/{slug}
</code></pre></li>
</ul>

<p>Then edit your Offers section, and give it the following Entry URI Format:</p>

<ul>
<li><p>Craft 2:</p>

<pre><code>{relatedBrand.first().uri}/{slug}
</code></pre></li>
<li><p>Craft 3:</p>

<pre><code>{relatedBrand.one().uri}/{slug}
</code></pre></li>
</ul>

<p>Basically you’re telling Craft when defining an offer entry’s URI, to start with its related brand’s URI, and then tack on the offer’s slug as an additional segment.</p>

<p>If my assumption is wrong, and you don’t want to give brands a similar URI format, then just build the whole thing out from your Offers section:</p>

<ul>
<li><p>Craft 2:</p>

<pre><code>{relatedBrand.first().category.first().uri}/{relatedBrand.first().slug}/{slug}
</code></pre></li>
<li><p>Craft 3:</p>

<pre><code>{relatedBrand.one().category.one().uri}/{relatedBrand.one().slug}/{slug}
</code></pre></li>
</ul>

<p>(I’m also assuming that the brands’ category field’s handle is <code>category</code>. If not, replace <code>category</code> with the real handle.)</p>

<blockquote>
  <p>Brand has a 'shortName' property.</p>
</blockquote>

<p>If that is a custom field that you would like to use instead of the brand entries’ slugs, just replace <code>slug</code> with <code>shortName</code> where appropriate.</p>

CC BY-SA 3.0
2018-01-21T23:49:43.400Z
Amazing Brandon - thank you so much for this!
JMKelley
CC BY-SA 3.0
2018-01-22T23:47:11.113Z
Hi Brandon, is it possible to use the relatedBrands category uri with the offer url?
JMKelley
CC BY-SA 3.0
2018-01-23T03:16:41.987Z
@JMKelley as in, don’t include the brand segment - just category/offer?
Brandon Kelly
CC BY-SA 3.0
2018-01-23T09:30:54.900Z
Hi Brandon, I mean just so it keeps the URL structure for google e.g. **Brands = /category/brand**, then offers = **/category/relatedbrand/offer** I've tried a few but it seems to hang and fail :(
JMKelley
CC BY-SA 3.0
2018-01-21T20:12:41.033Z
2018-01-21T20:12:41.033Z
Brandon Kelly
<p>I'm currently trying to get my URL's to be like the following:</p>

<pre><code>category/brand/offer/
</code></pre>

<ul>
<li>Category has a title </li>
<li>Brand has a 'shortName' property.</li>
<li>Offer has a title</li>
</ul>

<p>My plan is to have it so that it goes something like <strong>fashion/asos/50-off</strong></p>

<pre><code>{parent.uri}/offers/{slug}
</code></pre>

<p>I've tried quite a few variations but can't seem to get it right, still loads a 404 page or throws an error in the dashboard when trying to save entries again.</p>

<p>Any help would be brilliant!</p>

<p><strong>EDIT</strong></p>

<ul>
<li>Offer entries are related via the relatedBrand entry field.</li>
<li>Offer has not category related to it.</li>
<li>Brands have a category field.</li>
</ul>

CC BY-SA 3.0
2018-01-20T23:14:34.977Z
Do you already have relationships set up between your offer entries and their category & brand? What type of fields are you using, and what are their handles? Are they required?
Brandon Kelly
CC BY-SA 3.0
2018-01-21T13:00:28.647Z
Hi Brandon,

Yes, offers have a relatedBrand entries field. e.g. 50% off asos has a field where you attach a relatedBrand e.g. asos. Brand entries have a category field but offers don't. **edited** the question to include more info.
JMKelley
<entries><url><routing>
Entry URL Format
# Entry URL Format

(Asked by: username_0 on 2018-01-20)

I'm currently trying to get my URL's to be like the following:
category/brand/offer/


Category has a title 
Brand has a 'shortName' property.
Offer has a title

My plan is to have it so that it goes something like fashion/asos/50-off
{parent.uri}/offers/{slug}

I've tried quite a few variations but can't seem to get it right, still loads a 404 page or throws an error in the dashboard when trying to save entries again.
Any help would be brilliant!
EDIT

Offer entries are related via the relatedBrand entry field.
Offer has not category related to it.
Brands have a category field.

**Tags:** entries, url, routing
> **Comments:**
> **username_1**: Do you already have relationships set up between your offer entries and their category & brand? What type of fields are you using, and what are their handles? Are they required?  
> **username_0**: Hi Brandon,  Yes, offers have a relatedBrand entries field. e.g. 50% off asos has a field where you attach a relatedBrand e.g. asos. Brand entries have a category field but offers don't. **edited** the question to include more info.  

---

## 1 answers

### Answer by username_1 on 2018-01-21. Score: 7 | Accepted answer

There are two ways you can set that up, depending on whether you want Brand entries to have a similar URI format (just without the 3rd segment), e.g. category/brand.
Assuming you do, edit your Brands section, and give it the following Entry URI Format:

Craft 2:
{category.first().slug}/{slug}

Craft 3:
{category.one().slug}/{slug}


Then edit your Offers section, and give it the following Entry URI Format:

Craft 2:
{relatedBrand.first().uri}/{slug}

Craft 3:
{relatedBrand.one().uri}/{slug}


Basically you’re telling Craft when defining an offer entry’s URI, to start with its related brand’s URI, and then tack on the offer’s slug as an additional segment.
If my assumption is wrong, and you don’t want to give brands a similar URI format, then just build the whole thing out from your Offers section:

Craft 2:
{relatedBrand.first().category.first().uri}/{relatedBrand.first().slug}/{slug}

Craft 3:
{relatedBrand.one().category.one().uri}/{relatedBrand.one().slug}/{slug}


(I’m also assuming that the brands’ category field’s handle is category. If not, replace category with the real handle.)

Brand has a 'shortName' property.

If that is a custom field that you would like to use instead of the brand entries’ slugs, just replace slug with shortName where appropriate.

> **Comments:**
> **username_0**: Amazing Brandon - thank you so much for this!  
> **username_0**: Hi Brandon, is it possible to use the relatedBrands category uri with the offer url?  
> **username_1**: @JMKelley as in, don’t include the brand segment - just category/offer?  
> **username_0**: Hi Brandon, I mean just so it keeps the URL structure for google e.g. **Brands = /category/brand**, then offers = **/category/relatedbrand/offer** I've tried a few but it seems to hang and fail :(  

---

