# Using Fragments

# Querying fragments

To query a list of fragments in a zone to display in your templates:

{% set fragments = craft.fragments.zone('myZoneHandle').all() %}

Once you have queried the list of fragments, you can access the fields the same way you do for Entries.

{% for fragment in fragments %}
    <h1>{{ fragment.textField }}</h1>
    <img src="{{ fragment.imageField.one().url() }}" />
{% endfor %}

To target only fragments of a certain fragment type, modify the previous query like this:

{% set fragments = craft.fragments.zone('myZoneHandle').type('myFragmentTypeHandle').all() %}

# Fragment visibility

By default, fragments created in a zone will always be included when the zone is queried.

To override this, each fragment can be configured to be included or excluded from the zone based on the current page URL using the visibility rules.

Currently, only URL rules (full paths and wildcards) are allowed.

Editing a fragment

# Fragments field

The Fragments field allows your content editors to select fragments from all or some of the zones available.

Fragments