Your sites Log in Sign up Menu

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.


2 months ago, 5 replies   developers   embed-file   partial   Improve this 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 4 months ago · Improve this 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 4 months ago · Improve this answer

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

Answered 4 months ago · Improve this 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 2 months ago · Improve this 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 2 months ago · Improve this answer