Are server-side includes possible with Shopify?

Highlighted
Tourist
7 0 2

Howdy. 

 

I've recently moved my web site over to Shopify. My old web site was coded using HTML and php and I used to use a lot of server-side include code to insert snippets of code from other files which were used for when the same code would appear on multiple (but not all) pages, at the bottom of blog posts, for example, to insert the author details.

Kinda like the following:

 

<?php include 'include.php';?>

I've had a look around but I cannot see anything like this which will work in the HTML editor for my blog posts and other pages. Editing the theme files is not an option since I may want the snippet to appear at different points up and down the page depending on the content. I've tried to use the liquid snippet include code but this does not work when used outside of the theme or layout files.

 

Am I missing something? It seems like this should be possible but I cannot find any advice on it.

0 Likes
Highlighted
Pathfinder
103 8 19

Hey there.  You could pull script info using JavaScript on specific posts.  Look for the <> at the top right of the Rich Text Editor to edit the code of that specific article.

 

For pulling using Liquid, which would work better you would need to edit the templates.  However you could set it up ahead of time based on tags, or Titles, etc to show on specific Pages using IF statements, or setup different templates based on what your posting.

0 Likes
Highlighted
Tourist
7 0 2

Thanks for the reply. For my needs it may be better to use Javascript includes as I need flexibility to insert the included content at different points in the article and not just at the end for example.

 

I'll have another play around with it. Thanks.

0 Likes
Highlighted
Tourist
7 0 2

Ok, I've had the chance to play around with this a little and I still can't get any of the various methods of including external HTML to work.

 

I've tried using Javascript, including calling the files from an external server and it isn't playing ball.

 

Does anyone have a working solution to this?

0 Likes
Highlighted
New Member
4 0 0

Following.  I'm a noob with coding but I figured there's got to be something available for this out there.

 

For me, I've got a "New Sellers Checklist" I want to post in multiple places on my website (including in an autogenerated email, if that's possible), but I want to be able to make changes to it as desired and have it automatically update everywhere else.

 

I've been googling this stuff for like 2 hours, I didn't think it would be this hard.  I've come across the term "server side include" and found myself getting into javascript and php for the first time as well as github.  Is there not an easier way?  lol

0 Likes