6

I'd like to embed an HTML file into an MkDocs/Material page.

I'm trying something like what's below, but getting a 404 error.

Any idea of the right way to do this?

<div class="map">
  <iframe src="map.html"></iframe>
</div>

For what it's worth, a link like this does work, but I'd like the option to embed it in the current page.

[Show a map](map.html)
AJ Friend
  • 703
  • 1
  • 7
  • 16

2 Answers2

1

404 error seems that map.html is located somewhere else, while [show a map](map.html) may generate correct link. map.html is relative to viewing page, so I recommend to:

  • get absolute url of map.html file, e.g. When you click on Show a map what is absolute URL in browser location bar?
  • put that absolute URL into iframe src="absolute url"
  • you may make the absolute url relative - based on address current address in location bar
Tomas Kulhanek
  • 867
  • 1
  • 10
  • 18
0

Actually the index.md files behave differently. Relative paths work with them, but I also found a workaround for keeping it at relative paths: I went up one level to root then I used it as if it in the folder that gets generated in the site folder when you run mkdocs build See it in my sample docs here: https://agu3rra.github.io/volpy/ Link to the repo is on the top right corner.

Cheers!

Andre Guerra
  • 1,117
  • 1
  • 9
  • 18