How to embed a text file inside html?
Solution 1
Since you are already using Jekyll, just use its built-in include mechanism:
{% include stuff.txt %}
Solution 2
If 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
Solution 3
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");
?>
Solution 4
This actually seems to work:
<object width="1000" height="200" data="stuff.txt"></object>
Solution 5
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.
Jim Maas
I'm a biologist with most of my original training and experience in agriculture. Subsequently I moved into mathematical biology and hence programming utilizing several languages including R and Julia.
Updated on June 13, 2022Comments
-
Jim Maas almost 2 years
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?