Insert external html file using iframe in Sphinx

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

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

The html file is in the same directory as my .rst , but the graph is not displayed, and I get the file could not be found error.

However, if I insert an external html file into the _build/html directory, the graph is displayed in order. How to insert this html file correctly so that the graph is embedded automatically when I make html ?

A working example of what I want.

+5
source share
2 answers

You can put the filename.html file in the source/_static . Then it will be copied to build/html/_static , so you have to replace the iframe attribute with src="_static/filename.html" .

+7
source

You can also include the file directly:

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

Maybe not the way you wanted, but it can help others coming here from Google ...

+6
source

Source: https://habr.com/ru/post/1247736/


All Articles