How to get the URL containing the sort parameters

Topic summary

Need to detect the current collection page URL including the active sort_by query parameter, so different images can be shown depending on the selected sorting method. The examples given are collection URLs such as ?sort_by=manual and ?sort_by=created-descending.

Key issue:

  • Standard Shopify/Liquid URL outputs like canonical_url and routes do not include the query string.
  • Because of that, the current approach of checking the full URL for conditional branching is not working.

Goal:

  • Output or access the current URL with the sort parameter attached.
  • Use that value to switch image display based on the sort type.

Status:

  • No solution is provided in the discussion text.
  • The question remains open: the unresolved point is how to access query parameters like sort_by from the current page URL in this Store Design context.
Summarized with AI on March 5. AI used: gpt-5.4.

I would like to sort the images according to the type of sorting.

Example
https://example.com/collections/exampleA?sort_by=manual
https://example.com/collections/exampleA?sort_by=created-descending

I tried to get the current url and make a conditional branch, but I couldn’t find a way to get the current url.
The canonical_url and routes URLs could not output the URL containing sort_by=manual.
Is there any way to output URLs that include sort_by=manual?

Please let me know.