# blog.jinja


**Route:** `/blogs/{slug}`
**Path Operation:** `blogs`

Detail page for a single blog post.


## Variables

| Variable | Type |
|----------|------|
| `blog` | BlogPost |
| `store` | Store |
| `session` | Session |



## BlogPost Properties

| Property | Description |
|----------|-------------|
| `blog.id` | Blog ID |
| `blog.title` | Blog title |
| `blog.slug` | URL slug |
| `blog.snippet` | Short summary (HTML) |
| `blog.content` | Full post body (HTML — use `\| safe`) |
| `blog.published_at` | ISO date string |
| `blog.cover` | `BlogPostMedia` — see below |
| `blog.seo` | `SEO` metadata |
| `blog.category` | `BlogCategoryShort` (`id`, `name`, `slug`) — optional |
| `blog.tags` | List of `BlogTag` (`id`, `name`, `slug`) |
| `blog.related_posts` | List of `BlogPost` |
| `blog.recommended_product_ids` | List of product IDs |
| `blog.related_products` | List of `Product` (only present on the detail page when the post has recommended products) |

## BlogPostMedia / ImageURLs

| Property | Description |
|----------|-------------|
| `cover.image.full_size` | Full-size image |
| `cover.image.large` | Large variant |
| `cover.image.medium` | Medium variant |
| `cover.image.small` | Small variant |
| `cover.image.thumbnail` | Thumbnail |
| `cover.alt_text` | Alt text |

## Example

```twig
{% extends "layout.jinja" %}

{% block title %}{{ blog.title }} – {{ store.name }}{% endblock %}

{% block content %}
  <article>
    {% if blog.cover and blog.cover.image %}
      <img src="{{ blog.cover.image.large }}" alt="{{ blog.title }}">
    {% endif %}

    <h1>{{ blog.title }}</h1>

    {% if blog.published_at %}
      <time datetime="{{ blog.published_at }}">{{ blog.published_at }}</time>
    {% endif %}

    {{ blog.content | safe }}

    {# Tags #}
    {% if blog.category %}<span>{{ blog.category.name }}</span>{% endif %}
    {% for tag in blog.tags %}
      <span>{{ tag.name }}</span>
    {% endfor %}
  </article>

  {# Related products (only present when the post has recommended_product_ids) #}
  {% if blog.related_products | default([]) | length > 0 %}
    <section>
      <h2>{{ _("Featured Products") }}</h2>
      {% for product in blog.related_products %}
        <a href="/products/{{ product.slug }}">{{ product.name }}</a>
      {% endfor %}
    </section>
  {% endif %}

  {# Related posts #}
  {% if blog.related_posts | length > 0 %}
    <section>
      <h2>{{ _("You may also like") }}</h2>
      {% for related in blog.related_posts %}
        <a href="/blogs/{{ related.slug }}">{{ related.title }}</a>
      {% endfor %}
    </section>
  {% endif %}
{% endblock %}
```

