20

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.

Seanny123
  • 8,776
  • 13
  • 68
  • 124
shrgm
  • 1,315
  • 1
  • 10
  • 20

2 Answers2

28

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...

Ami Tavory
  • 74,578
  • 11
  • 141
  • 185
ostrokach
  • 17,993
  • 11
  • 78
  • 90
23

You could put the file filename.html in your source/_static directory. It would then be copied into build/html/_static, so you would have to replace the iframe attribute by src="_static/filename.html".

Émilien Tlapale
  • 903
  • 5
  • 11
  • See also https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_static_path – MEI Dec 11 '20 at 11:17