I'm trying to create a script for my Hugo website that will help streamline posting. The issue I'm facing is that when I run `hugo serve` in the script, it takes over the terminal, preventing me from returning to the script. When I hit Ctrl-C to stop `hugo serve`, it also exits my whole script. I want to know if there's a way to run `hugo serve`, check my site in Firefox, and then continue with the script without it getting interrupted. Here's a snippet of my script:
`echo "Move to next step [Y] or exit [q]?"`
`read -r editing_finished`
`if [ $editing_finished = q ]; then`
`exit`
`elif [ $editing_finished = Y ]; then`
`# Step 6 Run hugo serve`
`cd ../../../`
`# Run hugo local server and display in firefox`
`hugo serve & firefox http://localhost:1313/`
`fi`
Any help would be appreciated!
3 Answers
You might want to open a new terminal window for Hugo. It can keep your current terminal free for script execution.
If you run `hugo serve & firefox ...` it should only let Hugo output texts while Firefox takes over the input. You can silence Hugo's output with `&> /dev/null`. To stop the server later, you could track its process ID by doing `hugo serve & hugopid="$!"` and then kill that process when you're done.
Instead of changing directories in your script, consider using the full path to your Hugo installation. For example: `/path/to/hugo serve`. This can help avoid issues related to directory changes.

Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically