A space to discuss online store customization, theme development, and Liquid templating.
Hello,
I am using application proxies, however I would like to add the following tag to the head for the proxy page
<meta name="robots" content="noindex"> to prevent the proxied page being indexed via a search engine.
I can add this in the page, however this is not respected as the meta tag needs to be in the head, however I do not have access to the head of the document from an application proxy. Does anyone have a way of adding an application proxy page that is not indexed by search engines?
There are a couple of things going on here. One, an Application Proxy is initiated with a Javascript callback to an endpoint. It is not considered to be a page. So what you are asking is more "If I place a Javascript callback in Liquid, can I ensure there is a meta tag in the theme template that renders that Javascript?"
That becomes a bit of a chicken and egg problem. Most of the time, Liquid renders a giant string of HTML, including Javascript, which then gets sent to the browser, so using Javascript to append that needed metatag to the HEAD becomes your actual chore. Has nothing at all to do with Application Proxy. Try seeing if you can affect change that way, and then you could simply ensure you have that Javascript firing before the completed HEAD. You might find that near impossible, so second best thing is just to ensure the merchant can paste that tag into those specific theme HEAD elements rendered when the App Proxy is used.
Hey HunkyBill,
Thanks for the reply.
I am noticing that some of the application proxies are indexed by search engines and we would like them not to be. It looks like the only option may be having the merchants add a code snippet to the head in the form of
{% if request.path contains '/apps/proxy_base' %} <meta name="robots" content="noindex"> {% endif %}
However I was hoping I could find a way to do this without having the merchant edit their theme files.
I see. You are using the Proxy URL itself instead of a JS callback... OK..yes.. well in that case, you know Shopify returns the content_for_header and sandwiches the returned Liquid from your Proxy into the theme header and footer chrome, so yes, that would be the place to stick in some custom copy&paste Liquid to take care of your needs.
I know this is an old thread, but for anyone looking to do this still - here is how I did it:
Referencing this google documentation article on noindex
, there are two ways to implement noindex
: as a <meta>
tag and as an HTTP response header.
Since proxy pages do not have any control over the rendered page's <meta>
tags, I opted to use the X-Robots-Tag
response header option, which was successfully forwarded along to my proxy page.
Here is how this looks in an application proxy environment:
On your server, before you return an app proxy response, set the X-Robots-Tag
header to the value of noindex
.
An example in node.js it would be something like this:
response.setHeader("X-Robots-Tag", "noindex");
Do note that Shopify does strip several disallowed headers from your proxy response however the X-Robots-Tag
is an allowed header here so it will be be forwarded along to the HTTP response that Shopify sends when your proxy page is requested in the browser.
You can check if it worked by navigating to your proxy page in the browser and and inspecting the request to the HTML document in the console and you should see the X-Robots-Tag
header being forwarded along.