How can I remove '/collections' from the URL in the Dawn theme?

Hi everyone,

Im using the dawn theme.

Im trying to work out how to remove /collections from the url for seo reasons.

Ive seen a few tutorials which are for different themes but cant seem to work it out for dawn.

Step 1: Back up your theme!

First, you’ll want to take a backup copy of your theme. Just in case.

Step 2: Find the code to remove

For this example, I’m using an old version of Turbo (6.2) by Out of the Sandbox.

In the Shopify admin, go to Online Store → Themes → select the … → Edit Code. Search your theme files for within: collection.

This part can be a bit tricky to locate because Shopify doesn’t have a theme-wide search. So you have to go file by file. For this version of Turbo, the code I need to edit is in the snippets/product-details.liquid file and the snippets/product-thumbnail.liquid file.

Since each theme is different you may need to find the file for the product-grid or product-loop. If you still aren’t sure where this code is, you can search through each snippet file. There are Chrome extensions to search through your Shopify theme files, but I avoid using Chrome which is a story for another day.

Once you’ve found the within: collection we want to remove only that part.

We’ll end up with something like this:

Before:

{{ product.url | within: collection }}

After:

{{ product.url }}

You may need to search a few times for that line of code to make sure the | within: collection is removed for multiple spots. Many themes have the same piece of code duplicated.

Save the files you’ve edited and check on your results.

Step 3: Test the pages

Anytime you edit the theme files, you’ll want to check right away to make sure you didn’t break anything.

Shopify caches pages LIKE CRAZY so it may take a few minutes for your changes to reflect on the live site.

To test your changes, select a collection and navigate to a random product. In your URL bar, it should not have the collection or collection name.

Step 4: Create redirects

Assuming your site is live and you’ve already had your collection base product URLs indexed, don’t forget to create URL redirects. Forgetting to do this important piece will cause potential customers to land on an error page.

Ive searched all my snippets folder for within:

Unfortunately i think Dawn theme may use a different line of code. Nothing at all.

Heres product-media.liquid and product-thumbnail liquid. Ive also put pagination in here as this to me would make the most sense, hoping someone can see the code in here.

Product Media

{% comment %}
Renders product media

Accepts:

  • media: {Object} Product Media object
  • loop: {Boolean} Enable video looping (optional)
  • variant_image: {Boolean} The media associated with a variant

Usage:
{% render ‘product-media’,
media: media,
loop: section.settings.enable_video_looping,
variant_image: true
%}
{% endcomment %}

{%- if media.media_type == ‘image’ -%}
<img
class=“global-media-settings global-media-settings–no-shadow”
srcset=“{%- if media.preview_image.width >= 550 -%}{{ media.preview_image | image_url: width: 550 }} 550w,{%- endif -%}
{%- if media.preview_image.width >= 1100 -%}{{ media.preview_image | image_url: width: 1100 }} 1100w,{%- endif -%}
{%- if media.preview_image.width >= 1445 -%}{{ media.preview_image | image_url: width: 1445 }} 1445w,{%- endif -%}
{%- if media.preview_image.width >= 1680 -%}{{ media.preview_image | image_url: width: 1680 }} 1680w,{%- endif -%}
{%- if media.preview_image.width >= 2048 -%}{{ media.preview_image | image_url: width: 2048 }} 2048w,{%- endif -%}
{%- if media.preview_image.width >= 2200 -%}{{ media.preview_image | image_url: width: 2200 }} 2200w,{%- endif -%}
{%- if media.preview_image.width >= 2890 -%}{{ media.preview_image | image_url: width: 2890 }} 2890w,{%- endif -%}
{%- if media.preview_image.width >= 4096 -%}{{ media.preview_image | image_url: width: 4096 }} 4096w,{%- endif -%}
{{ media.preview_image | image_url }} {{ media.preview_image.width }}w”
sizes=“(min-width: 750px) calc(100vw - 22rem), 1100px”
src=“{{ media.preview_image | image_url: width: 1445 }}”
alt=“{{ media.alt | escape }}”
loading=“lazy”
width=“1100”
height=“{{ 1100 | divided_by: media.preview_image.aspect_ratio | ceil }}”
data-media-id=“{{ media.id }}”
{% if variant_image %}class=“product__media-item–variant”{% endif %}

{%- else -%}
{%- if media.media_type == ‘model’ -%}

{%- else -%} {%- endif -%} {%- if media.media_type == 'model' -%} {%- render 'icon-3d-model' -%} {%- else -%} {%- render 'icon-play' -%} {%- endif -%} {{ media.preview_image.alt | escape }} {%- case media.media_type -%} {%- when 'external_video' -%} {%- assign video_class = 'js-' | append: media.host -%} {%- if media.host == 'youtube' -%} {{ media | external_video_url: autoplay: true, loop: loop, playlist: media.external_id | external_video_tag: class: video_class, loading: "lazy" }} {%- else -%} {{ media | external_video_url: autoplay: true, loop: loop | external_video_tag: class: video_class, loading: "lazy" }} {%- endif -%} {%- when 'video' -%} {{ media | media_tag: image_size: "2048x", autoplay: true, loop: loop, controls: true, preload: "none" }} {%- when 'model' -%} {{ media | media_tag: image_size: "2048x", toggleable: true }} {%- endcase -%}

{%- if media.media_type == ‘model’ -%}

<button
class=“button button–full-width product__xr-button”
type=“button”
aria-label=“{{ ‘products.product.xr_button_label’ | t }}”
data-shopify-xr
data-shopify-model3d-id=“{{ media.id }}”
data-shopify-title=“title”
data-shopify-xr-hidden

{% render ‘icon-3d-model’ %}
{{ ‘products.product.xr_button’ | t }}

{%- else -%} {%- endif -%} {%- endif -%}

Product thumbnail

{% comment %}theme-check-disable ImgLazyLoading{% endcomment %}
{% comment %}
Renders a product thumbnail with a modal-opener

Accepts:

  • media: {Object} Product Media object
  • position: {String} Position of the media. Used for accessible label.
  • loop: {Boolean} Enable video looping (optional)
  • modal_id: {String} The product modal that will be shown by clicking the thumbnail
  • xr_button: {Boolean} Renders the “View in your space” button (shopify-xr-button) if the media is a 3D Model
  • media_width: {Float} The width percentage that the media column occupies on desktop.
  • lazy_load: {Boolean} Image should be lazy loaded. Default: true (optional)

Usage:
{% render ‘product-thumbnail’,
media: media,
position: forloop.index,
loop: section.settings.enable_video_looping,
modal_id: section.id
%}
{% endcomment %}

{%- if media.media_type == 'video' or media.media_type == 'external_video' -%} {% render 'icon-play' %}
{{ media.preview_image.alt | escape }}
{{ 'products.product.video_exit_message' | t: title: product.title | escape }} {%- else -%}
{{ media.preview_image.alt | escape }}
{%- endif -%} {%- liquid case media.media_type when 'video' or 'external_video' render 'icon-play' when 'model' render 'icon-3d-model' else render 'icon-zoom' endcase -%}
{{ media.preview_image.alt | escape }}
{{ 'products.product.media.open_media' | t: index: position }}

{%- if media.media_type != ‘image’ -%}
{%- if media.media_type == ‘model’ -%}

{%- else -%}

{%- endif -%}


{%- if media.media_type == ‘model’ -%}
{{ ‘products.product.media.play_model’ | t }}
{%- render ‘icon-3d-model’ -%}
{%- else -%}
{{ ‘products.product.media.play_video’ | t }}
{%- render ‘icon-play’ -%}
{%- endif -%}

<img
srcset=“{% if media.preview_image.width >= 493 %}{{ media.preview_image | image_url: width: 493 }} 493w,{% endif %}
{% if media.preview_image.width >= 600 %}{{ media.preview_image | image_url: width: 600 }} 600w,{% endif %}
{% if media.preview_image.width >= 713 %}{{ media.preview_image | image_url: width: 713 }} 713w,{% endif %}
{% if media.preview_image.width >= 823 %}{{ media.preview_image | image_url: width: 823 }} 823w,{% endif %}
{% if media.preview_image.width >= 990 %}{{ media.preview_image | image_url: width: 990 }} 990w,{% endif %}
{% if media.preview_image.width >= 1100 %}{{ media.preview_image | image_url: width: 1100 }} 1100w,{% endif %}
{% if media.preview_image.width >= 1206 %}{{ media.preview_image | image_url: width: 1206 }} 1206w,{% endif %}
{% if media.preview_image.width >= 1346 %}{{ media.preview_image | image_url: width: 1346 }} 1346w,{% endif %}
{% if media.preview_image.width >= 1426 %}{{ media.preview_image | image_url: width: 1426 }} 1426w,{% endif %}
{% if media.preview_image.width >= 1646 %}{{ media.preview_image | image_url: width: 1646 }} 1646w,{% endif %}
{% if media.preview_image.width >= 1946 %}{{ media.preview_image | image_url: width: 1946 }} 1946w,{% endif %}
{{ media.preview_image | image_url }} {{ media.preview_image.width }}w”
src=“{{ media | image_url: width: 1946 }}”
sizes=“(min-width: {{ settings.page_width }}px) {{ settings.page_width | minus: 100 | times: media_width | round }}px, (min-width: 990px) calc({{ media_width | times: 100 }}vw - 10rem), (min-width: 750px) calc((100vw - 11.5rem) / 2), calc(100vw - 4rem)”
{% unless lazy_load == false %}loading=“lazy”{% endunless %}
width=“973”
height=“{{ 973 | divided_by: media.preview_image.aspect_ratio | ceil }}”
alt=“{{ media.preview_image.alt | escape }}”

{%- liquid case media.media_type when 'external_video' assign video_class = 'js-' | append: media.host if media.host == 'youtube' echo media | external_video_url: autoplay: true, loop: loop, playlist: media.external_id | external_video_tag: class: video_class, loading: "lazy" else echo media | external_video_url: autoplay: true, loop: loop | external_video_tag: class: video_class, loading: "lazy" endif when 'video' echo media | media_tag: image_size: "2048x", autoplay: true, loop: loop, controls: true, preload: "none" when 'model' echo media | media_tag: image_size: "2048x", toggleable: true endcase -%}

{%- if media.media_type == ‘model’ -%}

{%- if xr_button -%}
<button
class=“button button–full-width product__xr-button”
type=“button”
aria-label=“{{ ‘products.product.xr_button_label’ | t }}”
data-shopify-xr
data-shopify-model3d-id=“{{ media.id }}”
data-shopify-title=“title”
data-shopify-xr-hidden

{% render ‘icon-3d-model’ %}
{{ ‘products.product.xr_button’ | t }}

{%- endif -%}
{%- else -%}

{%- endif -%}
{%- endif -%}

Pagination

{% comment %}
Renders a set of links for paginated results. Must be used within paginate tags.

Usage:
{% paginate results by 2 %}
{% render ‘pagination’, paginate: paginate, anchor: ‘#yourID’ %}
{% endpaginate %}

Accepts:

  • paginate: {Object}
  • anchor: {String} (optional) This can be added so that on page reload it takes you to wherever you’ve placed your anchor tag.
    {% endcomment %}
{{ 'component-pagination.css' | asset_url | stylesheet_tag }}

{%- if paginate.parts.size > 0 -%}

{%- endif -%}

Unfortunatly nothing in there - i think dawn is using a different structure than within: collections.

This is my main product grid file.

{{ ‘template-collection.css’ | asset_url | stylesheet_tag }}
{{ ‘component-loading-overlay.css’ | asset_url | stylesheet_tag }}
{{ ‘component-card.css’ | asset_url | stylesheet_tag }}
{{ ‘component-price.css’ | asset_url | stylesheet_tag }}

{%- if section.settings.enable_quick_add -%}

{%- endif -%} {{ 'component-rte.css' | asset_url | stylesheet_tag }}

{%- style -%}
.section-{{ section.id }}-padding {
padding-top: {{ section.settings.padding_top | times: 0.75 | round: 0 }}px;
padding-bottom: {{ section.settings.padding_bottom | times: 0.75 | round: 0 }}px;
}

@media screen and (min-width: 750px) {
.section-{{ section.id }}-padding {
padding-top: {{ section.settings.padding_top }}px;
padding-bottom: {{ section.settings.padding_bottom }}px;
}
}
{%- endstyle -%}

{% comment %} Sort is the first tabbable element when filter type is vertical {% endcomment %} {%- if section.settings.enable_sorting and section.settings.filter_type == 'vertical' -%}

{{ 'products.facets.sort_by_label' | t }}

{%- assign sort_by = collection.sort_by | default: collection.default_sort_by -%} {% render 'icon-caret' %}
{{ 'products.facets.sort_button' | t }}

{%- if collection.results_count -%} {{ 'templates.search.results_with_count' | t: terms: collection.terms, count: collection.results_count }} {%- elsif collection.products_count == collection.all_products_count -%} {{ 'products.facets.product_count_simple' | t: count: collection.products_count }} {%- else -%} {{ 'products.facets.product_count' | t: product_count: collection.products_count, count: collection.all_products_count }} {%- endif -%}

{%- endif -%}
{{ 'component-facets.css' | asset_url | stylesheet_tag }} {%- if section.settings.enable_filtering or section.settings.enable_sorting -%} {%- endif -%}
{%- paginate collection.products by section.settings.products_per_page -%} {%- if collection.products.size == 0 -%}

{{ 'sections.collection_template.empty' | t }}
{{ 'sections.collection_template.use_fewer_filters_html' | t: link: collection.url, class: "underlined-link link" }}

{%- else -%}
    {%- for product in collection.products -%} {% assign lazy_load = false %} {%- if forloop.index > 2 -%} {%- assign lazy_load = true -%} {%- endif -%}
  • {% render 'card-product', card_product: product, media_aspect_ratio: section.settings.image_ratio, show_secondary_image: section.settings.show_secondary_image, show_vendor: section.settings.show_vendor, show_rating: section.settings.show_rating, lazy_load: lazy_load, show_quick_add: section.settings.enable_quick_add, section_id: section.id

    %}

  • {%- endfor -%}

{%- if paginate.pages > 1 -%}
{% render ‘pagination’, paginate: paginate, anchor: ‘’ %}
{%- endif -%}

{%- endif -%} {%- endpaginate -%}

{% schema %}
{
“name”: “t:sections.main-collection-product-grid.name”,
“class”: “section”,
“settings”: [
{
“type”: “range”,
“id”: “products_per_page”,
“min”: 8,
“max”: 24,
“step”: 4,
“default”: 16,
“label”: “t:sections.main-collection-product-grid.settings.products_per_page.label”
},
{
“type”: “range”,
“id”: “columns_desktop”,
“min”: 1,
“max”: 5,
“step”: 1,
“default”: 4,
“label”: “t:sections.main-collection-product-grid.settings.columns_desktop.label”
},
{
“type”: “header”,
“content”: “t:sections.main-collection-product-grid.settings.header__3.content”
},
{
“type”: “select”,
“id”: “image_ratio”,
“options”: [
{
“value”: “adapt”,
“label”: “t:sections.main-collection-product-grid.settings.image_ratio.options__1.label”
},
{
“value”: “portrait”,
“label”: “t:sections.main-collection-product-grid.settings.image_ratio.options__2.label”
},
{
“value”: “square”,
“label”: “t:sections.main-collection-product-grid.settings.image_ratio.options__3.label”
}
],
“default”: “adapt”,
“label”: “t:sections.main-collection-product-grid.settings.image_ratio.label”
},
{
“type”: “checkbox”,
“id”: “show_secondary_image”,
“default”: false,
“label”: “t:sections.main-collection-product-grid.settings.show_secondary_image.label”
},
{
“type”: “checkbox”,
“id”: “show_vendor”,
“default”: false,
“label”: “t:sections.main-collection-product-grid.settings.show_vendor.label”
},
{
“type”: “checkbox”,
“id”: “show_rating”,
“default”: false,
“label”: “t:sections.main-collection-product-grid.settings.show_rating.label”,
“info”: “t:sections.main-collection-product-grid.settings.show_rating.info”
},
{
“type”: “checkbox”,
“id”: “enable_quick_add”,
“default”: false,
“label”: “t:sections.main-collection-product-grid.settings.enable_quick_buy.label”
},
{
“type”: “header”,
“content”: “t:sections.main-collection-product-grid.settings.header__1.content”
},
{
“type”: “checkbox”,
“id”: “enable_filtering”,
“default”: true,
“label”: “t:sections.main-collection-product-grid.settings.enable_filtering.label”,
“info”: “t:sections.main-collection-product-grid.settings.enable_filtering.info”
},
{
“type”: “select”,
“id”: “filter_type”,
“options”: [
{
“value”: “horizontal”,
“label”: “t:sections.main-collection-product-grid.settings.filter_type.options__1.label”
},
{
“value”: “vertical”,
“label”: “t:sections.main-collection-product-grid.settings.filter_type.options__2.label”
},
{
“value”: “drawer”,
“label”: “t:sections.main-collection-product-grid.settings.filter_type.options__3.label”
}
],
“default”: “horizontal”,
“label”: “t:sections.main-collection-product-grid.settings.filter_type.label”,
“info”: “t:sections.main-collection-product-grid.settings.filter_type.info”
},
{
“type”: “checkbox”,
“id”: “enable_sorting”,
“default”: true,
“label”: “t:sections.main-collection-product-grid.settings.enable_sorting.label”
},
{
“type”: “header”,
“content”: “t:sections.main-collection-product-grid.settings.header_mobile.content”
},
{
“type”: “select”,
“id”: “columns_mobile”,
“default”: “2”,
“label”: “t:sections.main-collection-product-grid.settings.columns_mobile.label”,
“options”: [
{
“value”: “1”,
“label”: “t:sections.main-collection-product-grid.settings.columns_mobile.options__1.label”
},
{
“value”: “2”,
“label”: “t:sections.main-collection-product-grid.settings.columns_mobile.options__2.label”
}
]
},
{
“type”: “header”,
“content”: “t:sections.all.padding.section_padding_heading”
},
{
“type”: “range”,
“id”: “padding_top”,
“min”: 0,
“max”: 100,
“step”: 4,
“unit”: “px”,
“label”: “t:sections.all.padding.padding_top”,
“default”: 36
},
{
“type”: “range”,
“id”: “padding_bottom”,
“min”: 0,
“max”: 100,
“step”: 4,
“unit”: “px”,
“label”: “t:sections.all.padding.padding_bottom”,
“default”: 36
}
]
}
{% endschema %}

Hi, did you ever work this out? I’m trying to do it now.

Did any of you were able to solve this?

You can remove /collections from URL for better SEO: