Nested category navigation I am trying to achieve the following markup for my categories navigation:

&lt;h3&gt;&lt;a href="categoryurl"&gt;Top Category One&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href="categoryurl"&gt;Sub Category One A&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="categoryurl"&gt;Sub Category One B&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="categoryurl"&gt;Sub Category One C&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;&lt;a href="categoryurl"&gt;Top Category Two&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href="categoryurl"&gt;Sub Category Two A&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="categoryurl"&gt;Sub Category Two B&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="categoryurl"&gt;Sub Category Two C&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


If have the following code which is nearly working:

{% set categories = craft.categories.group('projectType').all() %}
{% for category in categories %}
  {% if category.level == 1 %}
    &lt;h3 class="h5"&gt;&lt;a href="{{ category.url }}"&gt;{{ category.title }}&lt;/a&gt;&lt;/h3&gt;
  {% endif %}
  {% if category.level == 2 %}
    &lt;li&gt;&lt;a href="{{ category.url }}"&gt;{{ category.title }}&lt;/a&gt;&lt;/li&gt;
  {% endif %}
{% endfor %}


I am just missing the wrapping &lt;ul&gt; tags around the subcategory list items. Is there a way I can achieve this? The category group is limited to 2 levels so I can use the category.level if statements without a problem.

Thanks for any pointers!
You'll need to use the {% nav %} tag to output nested &lt;ul&gt;s as documented here:
https://craftcms.com/guides/displaying-a-navigation-for-a-structure-section

{% set categories = craft.categories.group('projectType').all() %}
{% nav category in categories %}
  {% if category.level == 1 %}
    &lt;h3 class="h5"&gt;&lt;a href="{{ category.url }}"&gt;{{ category.title }}&lt;/a&gt;&lt;/h3&gt;
  {% else %}
  &lt;li&gt;&lt;a href="{{ category.url }}"&gt;{{ category.title }}&lt;/a&gt;&lt;/li&gt;
  {% endif %}
  {% ifchildren %}
    &lt;ul class="unstyled"&gt;
      {% children %}
    &lt;/ul&gt;
  {% endifchildren %}
{% endnav %}


This answer should help too:
https://craftcms.stackexchange.com/a/4453