How do I link an image to its own page? I'm new to Craft CMS and can't figure out how to link images with the code below to its own page. Any suggestions?

{% for asset in entry.mainImages %}

    &lt;a href="{# link to the image's page #}"&gt;
        &lt;img src="{{ asset.url('thumb') }}"&gt;
    &lt;/a&gt;

{% endfor %}
In Craft assets do not get "their own page" by default, but you can easily create them with a Dynamic Route. So go to Settings → Routes and add a new route with a number token, e.g. assets/&lt;number&gt; and route those URIs to a new template, e.g. assets/_entry.

With this route set up you can now link to an asset's entry page like so:

&lt;a href="{{ url('assets/' ~ asset.id) }}"&gt;
    &lt;img src="{{ asset.url('thumb') }}"&gt;
&lt;/a&gt;


In your assets/_entry.html template you do now query for your asset via its ID, which is now available as a variable named "number". Use the exit tag to 404 the request in case no asset was found for the given ID.

{% set asset = craft.assets.id(number).first() %}

{% if not asset %}
    {% exit 404 %}
{% endif %}

&lt;figure&gt;
    &lt;img src="{{ asset.url('fullscreen') }}"&gt;
    &lt;figcaption&gt;{{ asset.caption }}&lt;/figcaption&gt;
&lt;/figure&gt;