Embed external html file using iframe in Sphinx

shreyasgm picture shreyasgm · Apr 22, 2016 · Viewed 9.3k times · Source

I'm trying to embed an interactive graph, which is saved as an html file, in a reStructuredText document using iframe:

.. raw:: html

    <iframe src="filename.html" height="345px" width="100%"></iframe>

The html file is in the same directory as my .rst file, but the graph does not display, and I'm getting a file could not be found error.

However, if I paste the external html file in the _build/html directory, the graph displays fine. How do I properly embed this html file, so that the graph is embedded automatically when I make html?

Working example of the thing that I want.

Answer

ostrokach picture ostrokach · Jul 11, 2017

You can also include a file directly:

.. raw:: html
   :file: filename.html

May not be what you wanted, but may help others coming here from google...