from Hacker News

Pre-rendering static websites with the 23 year-old wget command

by tjholowaychuk on 8/27/19, 3:40 PM with 15 comments

  • by jake-low on 8/27/19, 5:06 PM

    Thank you for sharing this; I find the technique refreshingly simple.

    > You may have seen people achieve this with a more complex headless Chrome-based solution, but for many sites, this will be perfectly fine!

    Can you elaborate on the difference between using wget and a heavier solution? I assume the main difference is that a headless browser can execute JavaScript and then serialize the resulting DOM back to HTML, allowing you to build sites in client side frameworks (React, Vue) and then make static versions of them for deployment. Are there other benefits of using a full browser vs. simply using wget?

  • by pedrocx486 on 8/27/19, 4:43 PM

    The title makes it look like wget is obsolete. Why not use the original title?
  • by znpy on 8/27/19, 5:26 PM

    Wouldn’t it make more sense to generate the html and save it to the appropriate file from the blog generator itself?

    What if you have a page that is there but it’s not linked from any other page (a landing page for example)? It would never be pre-rendered.

  • by app4soft on 8/28/19, 3:36 AM

    It would be interesting to combine wget with HTMLDOC[0] for convert static websites to PDF book.

    [0] https://github.com/michaelrsweet/htmldoc

  • by combatentropy on 8/28/19, 3:44 PM

    Would it be less maintenance to use your web server's cache feature? Both Apache and Nginx can cache dynamic pages to static files.
  • by deedubaya on 8/27/19, 7:43 PM

    Ha, I remember this being a thing to pre-warm caches in java systems a zillion years ago. What was once old is new again.
  • by enriquto on 8/27/19, 5:23 PM

    wget is not a command, it is a program