Log in Sign up

Is there a way to embed one text file within another one?

I have a snippet of text I would like to appear in multiple places around my site. Is there a way I can 'include' it in the content of pages or reference it directly from a custom template?

I know I could create a partial within my template but I'm trying (for now) to keep content and structure seperate.


3 months ago, 6 replies   developers   embed-file   partial   Edit question

It's possible to do something like this in your template.

Let's say you have the snippet in the file /Pages/description.txt. That file contains the following:

Menu: no

Your site's description here...

The reason we add Menu: no is so the file does not appear on your site's menu.

You can now embed this file in your template source code, like so:

{{> /Pages/description.txt}}

You can even inject it before/after specific posts, using custom metadata like so in your template's entry.html file:

{{#entry}}
...
{{#metadata.show_description}}
{{> /Pages/description.txt}}
{{/metadata.show_description}}
...
{{/entry}}
Answered a year ago · Edit answer

I'm not OP, but I'm trying to do something similar. I've created a description.txt file under /Pages. on my archives.html template page, I've put {{> /Pages/description.txt}} just before the </body> tag—so it should be the last thing on the page. But for whatever reason, it's not showing up. I also tried triple mustaches {{{> /Pages/description.txt}}} but met with no success there either.

Answered a year ago · Edit answer

Could you email us a link to your site and we'll look at the specifics

Answered a year ago · Edit answer

This seems like a way to include description.txt in a template file. Useful.

Is there a way to include a content file in another content file? For example include description.txt within about.txt.

Answered 9 months ago · Edit answer

No, the embedding needs to be done at the template level. You could have a template file about.html which embeds both about.txt and description.txt though – does that make sense?

Answered 9 months ago · Edit answer

Can someone please give more detailed, specific information about how to embed the contents of a text file after every blog post? I'm using the Magazine template.

Answered 3 months ago · Edit answer