Hugo |> Dev Server Open Browser



IF YOU JUST SOLVED SOME PROBLEM, WELCOME TO DM qaRabbit ON TWITTER, OR CREATE A PULL REQUEST IN GITHUB REPO.

Why hugo dev server can’t open browser tab automatically?

Modify hugo source code will definitely solve this issue.

Or we can use two simpler ways:

  • use some programe to run command hugo server and open_browser in parallel

  • use simple command sleep

Here is the second way on macOS: (open command only works on macOS)

#!/bin/bash

LOCAL_URL=http://localhost:1313

run_after () {
  duration=${1:-3}
  sleep $duration
  echo 'After '$duration
  # change open command to proper one
  open --new -a "Google Chrome" --args $LOCAL_URL
}

run_after 1 &
hugo server

Reference: