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.
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.
First, you’ll want to take a backup copy of your theme. Just in case.
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.
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.
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:
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’ -%}
{%- 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 }}
Product thumbnail
{% comment %}theme-check-disable ImgLazyLoading{% endcomment %}
{% comment %}
Renders a product thumbnail with a modal-opener
Accepts:
Usage:
{% render ‘product-thumbnail’,
media: media,
position: forloop.index,
loop: section.settings.enable_video_looping,
modal_id: section.id
%}
{% endcomment %}
{%- 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 }}”
{%- 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:
{%- if paginate.parts.size > 0 -%}
{%- for part in paginate.parts -%}
{%- if paginate.next -%}
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 -%}
%}
{%- if paginate.pages > 1 -%}
{% render ‘pagination’, paginate: paginate, anchor: ‘’ %}
{%- endif -%}
{% 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?