<p>It's fairly straight forward. You could go with a single "layout" file and then a template file for each unique template that utilizes that simple header/footer layout</p>

<ul>
<li>templates/layouts/_layout.html </li>
<li>templates/index.html (homepage)</li>
<li>templates/products.html</li>
<li>templates/support.html</li>
<li>templates/contact.html</li>
</ul>

<p>Extending a layout:</p>

<pre><code>{% extends "layouts/_layout" %}
</code></pre>

<p>Your product template would then just need to be coded to handle the category handle in the URL.</p>

<p>For instance, listing entries (products) that are assigned to a category (untested):</p>

<pre><code>{# get categorySlug from URL segment 2 #}
{% set category = craft.request.getSegment(2) %}

{# get instance of category #}
{% set category = craft.categories.slug('categorySlug') %}

{# get entries related to the category instance #}
{% set entries = craft.entries.relatedTo(category) %}

{# loop through the entries #}
{% for entry in entries %}
    &lt;a href="{{ entry.url }}"&gt;{{ entry.title }}&lt;/a&gt;
{% endfor %}
</code></pre>

<p>That's obviously just an example, but should get you going in the right direction.</p>

<p>Related reading material:</p>

<ul>
<li><a href="https://craftcms.com/docs/templating/craft.request#getSegments" rel="nofollow">https://craftcms.com/docs/templating/craft.request#getSegments</a></li>
</ul>

CC BY-SA 3.0
2016-10-31T20:28:55.580Z
Thank you for the reply. How would you do a two level category? E.g. product category then type or size followed by the products detail page?
Midknight
CC BY-SA 3.0
2016-10-31T20:36:50.243Z
Same idea, 

{% 
    set category = craft.request.getSegment(2);
    set type = craft.request.getSegment(3);
    set size = craft.request.getSegment(4);
%}
Jarrett Barnett
CC BY-SA 3.0
2016-11-01T22:47:10.093Z
Sorry did you mean categorySlug in that first variable declaration?
Midknight
CC BY-SA 3.0
2016-11-01T23:36:48.793Z
Well it all depends on how you structure your URL. Simply change the number to fetch the correct URL segment. (A URL segment is the text between each set of forward slashes: e.g. website.com/segment1/segment2/segment3/segment4/
Jarrett Barnett
CC BY-SA 3.0
2016-11-02T03:51:24.823Z
Sorry I mean in your original response. 
{% set category = craft.request.getSegment(2) %}
{% set category = craft.categories.slug('categorySlug') %}
Midknight
CC BY-SA 3.0
2016-10-31T18:31:25.253Z
2016-10-31T18:31:25.253Z
Jarrett Barnett
<p>Thank you for your time and patience I'm a newbie to the Craft world. I've been all over the Craft Documentation and this site trying to figure out the best approach for a site I am putting together. The prototype I did makes sense however when it came time to put it into Craft I'm hesitant or lacking confidence in the setup. I just need a sound board to bounce off my setup.</p>

<p>Current Section setup:</p>

<ul>
<li>Home (Single)</li>
<li>Company (Single)</li>
<li>Products (Single and Structure with multiple entry types)

<ul>
<li>Product Category A

<ul>
<li>Type A

<ul>
<li>Size A</li>
<li>Size B</li>
</ul></li>
<li>Type B</li>
<li>Type C</li>
</ul></li>
<li>Product Category B

<ul>
<li>Product</li>
</ul></li>
<li>Product Category C

<ul>
<li>Type D</li>
<li>Type E</li>
</ul></li>
</ul></li>
<li>Support (Single)</li>
<li>Contact (Single)</li>
</ul>

<p>How would I best create a template structure for the products section? How can I setup categories to help create this structure? </p>

<p>URL would ideally be
site.com/products/product-category/product</p>

<p>or do I even need products? Just jump to the product-category?</p>

<p>I want to have a category page, comparison page (Size) and dedicated product page. The category page with the type category wouldn't need an intermediate page.</p>

<categories><structure><sections><setup>
Can someone help me with my site structure? Sections/Category setup
# Can someone help me with my site structure? Sections/Category setup

(Asked by: username_0 on 2016-10-28)

Thank you for your time and patience I'm a newbie to the Craft world. I've been all over the Craft Documentation and this site trying to figure out the best approach for a site I am putting together. The prototype I did makes sense however when it came time to put it into Craft I'm hesitant or lacking confidence in the setup. I just need a sound board to bounce off my setup.

Current Section setup:

* Home (Single)
* Company (Single)
* Products (Single and Structure with multiple entry types)
  + Product Category A
    - Type A
      * Size A
      * Size B
    - Type B
    - Type C
  + Product Category B
    - Product
  + Product Category C
    - Type D
    - Type E
* Support (Single)
* Contact (Single)

How would I best create a template structure for the products section? How can I setup categories to help create this structure?

URL would ideally be
site.com/products/product-category/product

or do I even need products? Just jump to the product-category?

I want to have a category page, comparison page (Size) and dedicated product page. The category page with the type category wouldn't need an intermediate page.

**Tags:** categories, structure, sections, setup

---

## 1 answers

### Answer by username_1 on 2016-10-31. Score: 0 | Accepted answer

It's fairly straight forward. You could go with a single "layout" file and then a template file for each unique template that utilizes that simple header/footer layout

templates/layouts/_layout.html 
templates/index.html (homepage)
templates/products.html
templates/support.html
templates/contact.html

Extending a layout:
{% extends "layouts/_layout" %}

Your product template would then just need to be coded to handle the category handle in the URL.
For instance, listing entries (products) that are assigned to a category (untested):
{# get categorySlug from URL segment 2 #}
{% set category = craft.request.getSegment(2) %}

{# get instance of category #}
{% set category = craft.categories.slug('categorySlug') %}

{# get entries related to the category instance #}
{% set entries = craft.entries.relatedTo(category) %}

{# loop through the entries #}
{% for entry in entries %}
    {{ entry.title }}
{% endfor %}

That's obviously just an example, but should get you going in the right direction.
Related reading material:

https://craftcms.com/docs/templating/craft.request#getSegments

> **Comments:**
> **username_0**: Thank you for the reply. How would you do a two level category? E.g. product category then type or size followed by the products detail page?  
> **username_1**: Same idea,   {%      set category = craft.request.getSegment(2);     set type = craft.request.getSegment(3);     set size = craft.request.getSegment(4); %}  
> **username_0**: Sorry did you mean categorySlug in that first variable declaration?  
> **username_1**: Well it all depends on how you structure your URL. Simply change the number to fetch the correct URL segment. (A URL segment is the text between each set of forward slashes: e.g. website.com/segment1/segment2/segment3/segment4/  
> **username_0**: Sorry I mean in your original response.  {% set category = craft.request.getSegment(2) %} {% set category = craft.categories.slug('categorySlug') %}  

---

