How to develop static website from golang. It should be server side. And it should call api too.
Basically you can work with traditional MPA (each page loaded fully - better for SEO) or SPA (Only 1 main page is fully loaded and the other pages are “injected” into this main template. Smaller and faster)
I use MPA for web sites and SPA for web apps.
- Use plain Go HTML templates. No framework needed.
- Use web server as endpoints that serves the pages
- You only need API if you want to add dynamic data into the templates
- Use //embed to create a single executable and upload to a VPS
- Use Cloudflare for DNS, caching etc…
Your question is too broad to give a detailed answer IMO.
Here is the simplest possible “Go web site” without templates. And here is my first static site (somewhat outdated MPA) that describes parts of my journey. My first attempt to grasp SPA. (using Go to render and Javascript to inject)
“Static website” and “should call API” do not compose well in my head…
As “static website” means “something that never changes” and “should call API” means “shall retrieve external information and reflect that on the website”.