Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add title logic in the <head> #87

Closed
wants to merge 3 commits into from
Closed

add title logic in the <head> #87

wants to merge 3 commits into from

Conversation

ludoboludo
Copy link
Contributor

@ludoboludo ludoboludo commented Jun 30, 2021

Why are these changes introduced?

About -> #77 .

What approach did you take?

Added logic to have something similar to what's shown in the issue

<!-- Homepage -->
<title>OS 2.0</title>

<!-- Product page -->
<title>{Product title} – OS 2.0</title>

<!-- Search results page with results found -->
<title>9 results found for "sandal" – Search results – OS 2.0</title>

<!-- Search results page with no results found -->
<title>No results found for "glasses" – Search results – OS 2.0</title>

<!-- Contact page in error state -->
<title>Error – Contact – OS 2.0</title>

Other considerations

Should we also add the filtering tags in the title ? When looking at Debut, it had:

{%- if current_tags -%}
  {%- assign meta_tags = current_tags | join: ', ' -%} &ndash; {{ 'general.meta.tags' | t: tags: meta_tags -}}
{%- endif -%}

Since now we're using a different filtering approach, it would need some new logic.

I could do something like this:

if request.page_type == 'collection'
  for filter in collection.filters
    for value in filter.values
      if value.active
        echo ' &ndash; '
        echo value.label
      endif
    endfor
  endfor
endif

And I would need to update the JS for filters so it updates the title the same way it currently updates the url with updateURLHash().


In the desired output above, we would add Error in the title to reflect an error in form submission. form.errors is something that can only be used within a form. I could use it to do an assign and check against that assign in theme.liquid but that seem like a scrappy solution.

It would be ideal if we didn't have to hard code the logic for the page title as it usually won't differ from theme to theme. I'm curious to hear what @Thibaut thinks about it.

Demo links

Checklist

@ludoboludo ludoboludo added the Category: Bug Something isn't working label Jun 30, 2021
@ludoboludo ludoboludo marked this pull request as ready for review July 5, 2021 15:35
Comment on lines 29 to 38
if request.page_type == 'collection'
for filter in collection.filters
for value in filter.values
if value.active
echo ' / '
echo value.label
endif
endfor
endfor
endif
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this to see how it would work for the filtering to show up. I would still need to add something in the JS to update the page title as it updates the updateURLHash() if we decide to do it this way.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems really granular to have theme devs update the title like this, especially as we release new features that could potentially impact it, e.g. collection filtering. I would remove for now until we have a better general sense of how we want to improve our approach to titles in our themes.

{%- liquid
capture seo_title
if request.page_type == 'search' and search.performed == true
if search.results_count == 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need this condition, you can leverage pluralized translations.

Comment on lines 29 to 38
if request.page_type == 'collection'
for filter in collection.filters
for value in filter.values
if value.active
echo ' / '
echo value.label
endif
endfor
endfor
endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems really granular to have theme devs update the title like this, especially as we release new features that could potentially impact it, e.g. collection filtering. I would remove for now until we have a better general sense of how we want to improve our approach to titles in our themes.

@ludoboludo ludoboludo requested a review from bertiful July 5, 2021 16:51
@tyleralsbury
Copy link
Contributor

Something else we need to think about is updating scripts like the facets to change the number of items in the title whenever the page updates as well, along with anywhere else that the page state updates and should reflect in the title.

Not sure about this one, but maybe the product page having the variant name instead of just the product name as well? That would need updating when options are selected as well. Not sure if this is desired.

@ludoboludo ludoboludo marked this pull request as draft August 9, 2021 16:18
@ludoboludo ludoboludo closed this Sep 14, 2021
@andrewetchen andrewetchen deleted the add-title-logic branch February 3, 2023 02:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants