> For the complete documentation index, see [llms.txt](https://docs.devhub.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.devhub.com/themes-and-custom-templates/advanced-examples/theme-module-templates.md).

# Theme module templates

## blog - posts list

This template controls both the "list" view for the blog module subpages. This includes the blog root, archive pages and category pages.

```html
{% if posts %}
    {% for post in posts %}
        <article itemscope="" itemtype="http://schema.org/BlogPosting">
            <h2 itemprop="name headline">
                <a href="{{ post.external_url or post.url(**post_url_params) }}" title="{{ post.title }}">{{ post.title }}</a>
            </h2>
            <p datetime="{{ post.date|datetimefmt(format='yyyy-MM-ddTHH:mm') }}" itemprop="datePublished dateModified">{{ post.date|datefmt(format='long') }}</p>
            {% if post.content %}
            <div itemprop="articleBody">
                {% if show_full_posts %}
                    {{ post.content|safe }}
                {% else %}
                    {% if post.featured_img %}
                        <p itemprop="image" itemscope itemtype="https://schema.org/ImageObject">
                            <img alt="{{ post.title }}" src="{{ post.featured_img.src }}" style="{{ post.featured_img.style }}" itemprop="image"/>
                        </p>
                    {% endif %}
                    <p>{{ post.content|striptags|truncatewords_html(75) }}</p>
                    <p><a href="{{ post.external_url or post.url(**post_url_params) }}" title="{{ post.title }}">{% trans %}Read more{% endtrans %}..</a></p>
                {% endif %}
            </div>
            {% endif %}
        </article>
    {% endfor %}
    <div>
        {% if posts.has_previous() %}
            <a href="{{ posts.prev_link }}">{% trans %}Previous Page{% endtrans %}</a>
        {% endif %}
        {% if posts.has_next() %}
            <a href="{{ posts.next_link }}">{% trans %}Next Page{% endtrans %}</a>
        {% endif %}
    </div>
{% else %}
    <p>{% trans %}No posts have been added{% endtrans %}
{% endif %}
```

## blog - post detail

This template controls the single post page for each blog post.

```html
<article class="post" itemscope="" itemtype="http://schema.org/BlogPosting">
    <h1 itemprop="name headline">{{ post.title }}</h1>
    <p datetime="{{ post.date|datetimefmt(format='yyyy-MM-ddTHH:mm') }}" itemprop="datePublished dateModified">{{ post.date|datefmt(format='long') }}</p>
    {% if post.content %}
    <div itemprop="articleBody">
        {{ post.content|safe }}
    </div>
    {% endif %}
</article>
```

## blog - recent posts

Widget used to show the recent posts on a site's blog. Normally used in footers or other parts of pages outside the main blog pages.

```html
{% for post in posts[:3] %}
    <div>
        <p>
            {% if post.featured_img %}
                <img alt="{{ post.title }}" src="{{ post.featured_img.src }}" />
            {% else %}
                <img alt="{{ post.title }}" src="/img/upload/blogdefault.jpg" />
            {% endif %}
        </p>
        <p><a href="{{ post.url(**post_url_params) }}">{{ post.title }}</a></p>
    </div>
{% endfor %}
```

## directory - cities\_list

```html
<div>
  <a href="{{ directory_root }}">{% trans %}Directory{% endtrans %}</a>{% if country_name %} > <a href="{{ country_href }}">{{ country_name }}</a>{% endif %} > {{ state_name }}
</div>
<h1>{{ site.business.business_name }} {% trans %}in{% endtrans %} {{ state_name }}</h1>
<ul>
  {% for city in cities %}
    <li><a href="{{ city.href }}">{{ city.city }}{% if city.number %} ({{ city.number }}){% endif %}</a></li>
  {% endfor %}
</ul>
```

## directory - countries\_list

### Basic list of countries

```html
<ul>
{% for country in countries %}
  <li><a href="{{ country.href }}">{{ country.country }}{% if country.number %} ({{ country.number }}){% endif %}</a></li>
{% endfor %}
</ul>
```

### List of countries and the states/provinces

```html
<ul>
{% for country in countries %}
  <li>
    <a href="{{ country.href }}">{{ country.country }}{% if country.number %} ({{ country.number }}){% endif %}</a>
    {% if country.states %}
      <ul>
        {% for state in country.states %}
          <li><a href="{{ state.href }}">{{ state.state_name }} - {{ state.state }}</a></li>
        {% endfor %}
      </ul>
    {% endif %}
  </li>
{% endfor %}
</ul>
```

## directory - sites\_list

```html
<div>
    <a href="{{ directory_root }}">{% trans %}Directory{% endtrans %}</a>{% if country_name %} > <a href="{{ country_href }}">{{ country_name }}</a>{% endif %} > <a href="{{ state_href }}">{{ state_name }}</a> > {{ city }}
</div>
<ul>
<h1>{{ site.business.business_name }} {% trans %}in{% endtrans %} {{ city }}, {{ state_name }}</h1>
{% for result in results %}
  <li>
    <a href="{{ result.site.formatted_url }}">{{ result.site.title }}</a>
    <span>{{ result.location.formatted_address }}</span>
  </li>
{% endfor %}
</ul>
```

## directory - statesprovs\_list

```html
<div>
  <a href="{{ directory_root }}">{% trans %}Directory{% endtrans %}</a>{% if country_name %} > {{ country_name }}{% endif %}
</div>
{% if country_name %}
<h1>{{ site.business.business_name }} {% trans %}in{% endtrans %} {{ country_name }}</h1>
{% endif %}
<ul>
{% for state in states %}
  <li><a href="{{ state.href }}">{{ state.state }}{% if state.number %} ({{ state.number }}){% endif %}</a></li>
{% endfor %}
</ul>
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.devhub.com/themes-and-custom-templates/advanced-examples/theme-module-templates.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
