I've got an index.html file for use with Jekyll and would like the contents of one paragraph in the HTML file to be called from a text file ("stuff.txt") located in the same directory as the index.html file.
Is there a simple HTML command to read in the text, preferably outwith the use of PHP or JavaScript?
I've got an index.html file for use with Jekyll and would like the contents of one paragraph in the HTML file to be called from a text file ("stuff.txt") located in the same directory as the index.html file.
Is there a simple HTML command to read in the text, preferably outwith the use of PHP or JavaScript?
Share Improve this question edited Jul 28, 2018 at 17:55 Nimeshka Srimal 8,9305 gold badges45 silver badges60 bronze badges asked Sep 18, 2014 at 9:44 Jim MaasJim Maas 1,7293 gold badges21 silver badges42 bronze badges 3- Take a look at this: stackoverflow.com/questions/6470567/… – Matheno Commented Sep 18, 2014 at 9:46
- " preferably without the use of PHP or JavaScript?" – danielg44k Commented Sep 18, 2014 at 9:48
- 1 "outwith" is as valid as "without" :-) – Jim Maas Commented Sep 18, 2014 at 9:50
5 Answers
Reset to default 6If you really do not wish to use js or php, here is a solution. Use the embed tag to embed the text file into your document. Otherwise, you can use an iframe too.
<embed src="stuff.txt">
Reference Link : http://www.quackit.com/html_5/tags/html_embed_tag.cfm
without php
<iframe src='stuff.txt' scrolling='no' frameborder='0'></iframe>
just tested and it works . Or try it with php as bellow
<iframe src='txt.php' scrolling='no' frameborder='0'></iframe>
and txt.php
<?php
echo file_get_contents("stuff.txt");
?>
This actually seems to work:
<object width="1000" height="200" data="stuff.txt"></object>
Since you are already using Jekyll, just use its built-in include mechanism:
{% include stuff.txt %}
You need to use PHP or Javascript, but there's an old-fashioned way that you can use called Server-Side Includes:
http://www.htmlgoodies.com/beyond/webmaster/article.php/3473341
You will need to rename your file to index.shtml
and write something like:
<!--#include file="stuff.txt" -->
Update per comment: You need to be on a server that supports SSI. From my experience, most shared hosting servers support it, but you might need to ask your host.