How to remove html boilerplate from compiled html output?

Hi all!
I’ve been trying to work with the new experimental html compilation feature to use it as an alternative to markdown in my static site. I have it just about working, but I’d like to remove from extra bits the compiler provides to the output that my static site generator already provides. For example, the compiler currently outputs the following in every file:

 <!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
  </head>
  <body>CONTENT HERE</body>
</html>

Is there any way to output say, only the tags?
Thanks!

Hi. Looking at typst/crates/typst-html/src/lib.rs at 494e6a64225261add59c3c9b1cd923bfdfa77961 · typst/typst · GitHub, the root element requires head, which adds the meta tags, and then the body is added. So no, you can’t remove them within Typst. This might become configurable at some point.

See My static-site blog based on astro and typst and One command to build blogs with Typst. Maybe you can get some help from @Myriad-Dreamin.

Gotcha, thanks for your help! I’m not at all skilled enough to have figured that out looking at the source.
I was looking at @Myriad-Dreamin 's implementation with Astro a little bit ago, I may end up just going that route for rebuilding my website :)

1 Like