How to Add Header and Footer in Grav CMS - header

I know how to add content in Grav CMS but i am facing problem in how to add a header section in Grav CMS. Please tell me where do i have to write the code for header and footer. In (.md) files or twig files?

As domsson already noted, there are more than a single way to do it in Grav
You can check implementation of it in (default) Quark theme:
templates/partials/base.html.twig, which is used by all other templates, have in needed location {% include 'partials/footer.html.twig' %} and footer.html.twig, in turn, contain all needed data for rendering on page
You can also see (use) idea from Open Publishing Space skeleton
{# display footer markdown page - hibbittsdesign.org #}
{% set content = pages.find('/footer').content %}
{% if content %}
{{ content|raw }}
{% endif %}
Here ordinary page (/footer) from site (editable as much as needed) used instead of template and have anything in it, it's content used as site-footer
If you have site with modular-pages only (like, f.e. Deliver skeleton), you can also (except using base-template as per p.1) add to all modular-collections
content:
items: #self.modular
…
page, which share common template (and data)

Related

How to use a Shopify Section across a Layout?

I have a section with content that can be edited from the Shopify Customizer. I use this section across multiple pages, but the content remains the same.
Is there a way to instead bind this section to a whole layout?
Because when you update the content, you have it re-enter it on every single page template that uses this section. I can have static HTML across all page templates that use a layout, but this isn't useful because the content needs to be editable from the Shopify Customizer.
You can have a section across a layout after all.
I was doing
layout/my-new-layout.liquid:
{% render 'section-component.liquid' %}
when I was supposed to be doing
layout/my-new-layout.liquid:
{% section 'section-component.liquid' %}
For reference
If you're trying to convert a template-only section to a layout-only section...
Remove the section JSON data from the template: templates/page.your-template.json.
Add a {% section 'your-section' %} in the layout (i.e. layout/my-new-layout.liquid).

Disable certain Shopify apps on certain pages

There are about 20 apps installed on our shop. Different apps are used on different pages. For example, there are apps which are used on the product page only.
However I see that all apps are loaded on every page. Looking into page source I see JavaScript function asyncLoad which is part of built-in {{ content_for_header }} variable. This function load scripts for all apps on every page. So, can I restrict this somehow? I mean - to avoid of downloading scripts/css/whatever of apps which I don't use on the specific page. For example, on the home page I need just a couple of apps active, not all 20 of them. Didn't find the answer in docs or Google.
It sounds like you've already figured out a lot about how Shopify allows apps to load their scripts, so you're most of the way there!
When I've needed to selectively disable apps, I have removed them from the asyncLoad function using something like the following:
{% capture modified_content_for_header %}{{ content_for_header }}{% endcapture %}
{% if template.name == 'index' %}
{% assign modified_content_for_header = modified_content_for_header | remove: 'some_app_url.js,' %}
{% endif %}
<!-- If you have a lot of templates you are checking, a case/when using template.name might be appropriate -->
{{ modified_content_for_header }}
I like using {% if template.name == value %} rather than {% if template contains value %} for template checks, as that ensures I don't accidentally get a false positive for a template suffix that contains one of the other template types for some reason, like a collection.alternate_product_layout or something silly like that.
Disclaimer: Messing with 3rd party apps by removing their script files may have unexpected side-effects, so always be sure to exercise caution and test thoroughly on an unpublished theme!

Shopify Liquid tag modify HTML?

I have shopify store. I want to amend HTML output of app.
basically app adds some Img tag which is not visible to client via CSS. I want to remove those Img tags from it.
{% include 'my-appinfo', app-arg-1: 'test' %}
As above we include app into theme.liquid file.

How to Add noindex for specific page in Shopify store

I have a Shopify store and I want to block search engines to index some products pages, I found this solution https://help.shopify.com/en/manual/promoting-marketing/seo/hide-a-page-from-search-engines?utm_source=gurucopy&utm_medium=link&utm_campaign=Gurus#undefined
{% if handle contains 'page-handle-you-want-to-exclude' %}
<meta name="robots" content="noindex">
{% endif %}
but I don't how I should make changes to block my pages
below my page link
mysite.com/products/product-26
mysite.com/products/kalita
Thank You
There is very handy way for doing it.. It works like a charm.. You can make use of metafields property for products provided by Shopify (look for tool called ShopifyFD for Google Chrome)
Create a metafield for the product(s) you want to hide from Google. Have a metafield with namespace as "seo" and key as "robots" and give value as "noindex" or "noindex, nofollow" based on what you need and "Save"
Now in your theme.liquid in head section, add the following
{% if product and product.metafields.seo and product.metafields.seo.robots %}
<meta name="robots" content="{{ product.metafields.seo.robots }}">
{% endif %}
Shopify have an API guide for doing this: Hide a resource from search engines and sitemaps:
POST /admin/api/2019-10/products/#{id}/metafields.json
{
"metafield": {
"namespace": "seo",
"key": "hidden",
"value": 1,
"value_type": "integer"
}
}
You might also want to check out their Developer Tools app, if you are using macOS — that will allow you to perform the post request, after you have authenticated using private app creds.

How to edit content on pages for Collection Tags in Shopify

When creating Collections in Shopify I can easily add Tags to them, which are then displayed on the Collections pages (in most of the themes I've used so far). The Collections page will typically show all the Tags for any Product within that Collection.
If you click the Tag it will go to a new page. I'm trying to find a way to edit those pages - it does not appear that this ability is built into Shopify, so I'm looking for the best solution.
There are easily over a hundred tags on this site too. My hope is to avoid writing a ton of conditional statements, but I fear that may be my only option.
Liquid - Example of what I'm thinking:
{% if current_tags == 'tag-name' %}
unique content for that tag
{% endif %}
Can anyone point me in a better direction?
The solution was simpler than I thought. I was using == when I should have been using 'contains'. Not that if your tags use spaces then you should type them exactly the same vs adding dashes to fill spaces.
Example:
{% if current_tags contains 'My Tag' %}
<!-- Custom HTML goes here -->
{% endif %}