问题
I have a custom theme in Big Cartel and I need to create an if statement using BC's own tags that looks at the page URL and then displays a tag.
For example, if url is homepage show this tag, if it is product page a, show this tag and so on...
Anyone have any idea how I can write that?
At the moment the theme has this:
<title>{{ page.name | remove: '-footer-' | remove: '-hide-' | remove: '-sidebar-' | remove: '-subnav-' | remove: '-f1-' | remove: '-f2-' | remove: '-f3-' }} | {{ store.name }}</title>
回答1:
There are a number of different conditions you could use for this, like checking the page name, page permalink, the full URL, or others. A full variable reference is available here: http://help.bigcartel.com/customer/portal/articles/772750-variables#page
Here's a couple examples:
{% if page.name == 'Home' %}code here {% endif %}
{% if page.permalink == 'home' %}
code here
{% elsif page.permalink == 'product' %}
more code here
{% endif %}
来源:https://stackoverflow.com/questions/23842539/change-meta-page-titles-on-big-cartel-dynamically