I have 3 questions on static v/s dynamic web development.
Definition
From what I can gather, a dynamic website is one where pages are constructed by the server by pulling content from a database before rendering to the user. A static website is basically one where every single page is set and rendered as is, with of course browser js interaction. Is that correct?
Usage
I intend to build a website for a small business. A limited amount of products, no login, no search and at this stage no cart/payment. I will be maintaining, editing and adding products on the site myself. Isn’t static better suited here? If yes, would it be feasible if at a later stage, it needs to be converted into a dynamic site?
Web Dev
Isn’t it a good idea to start doing static sites and get the hang of it before going into dynamic site dev?
Development - what’s the most efficient way to create and maintain a website
Production - what’s the most performant way to run a website
I suppose you mean “trendy” topic at the moment - static site generators, like Eleventy or GatsbyJS. They both give you ability to develop in dynamic manner - more efficient way and then they will generate static html pages for you on the build time, which seems to be more performant way to serve websites.
Thank you for your reply. No, I am not looking at trends. I am interested in building from scratch. And I just cannot see the benefits of going through the hassle of building a dynamic website when it would seem that a static one is adequate for such a simple site, at this stage.
I mean it’s your choice. To me it sounds crazy starting from more than 2 products on the website. Building just one product component/template and then just feeding it with the data seems much less hassle…
What @snigo said: a store is basically a canonical example of where you want a database-backed site. If it’s static it means you need to rewrite the site every time you add a product or sell a product. It is so much less hassle to have this backed by a database.
Static sites & static site generator tools are excellent for building out things that do not change much – for example a company website that contains information about the company. They are not particularly useful for things that are dynamic and change all the time, for example an online store for the company.
Thank you all for your kind help. @snigo thinks dynamic is for more than 2 products on the website, whereas you are saying that dynamic is for things that change all the time.
Let me be specific. Let’s say that there are 4 categories with 5 products in each category. And that there is not going to be any new product for at least one year.
So I create an html file for each of the 4 categories. And I just duplicate and edit each of them 5 times.
Is that feasible or does that sound crazy? I am just a newbie here
I’m not recommending anything different to @snigo. What happens when you sell something? Rebuild the site! What happens when something is unavailable? Rebuild the site!
Yes, it’s feasible to display the information (it’s completely infeasible for actually using it – what it would be is a catalogue, not a shop), it’s just much, much, much easier and much less error prone to put the information in a database then use something to refer the information using HTML templates rather than writing the same thing over and over and over again
Edit: this is kinda the point of programming. You have a process (in this case, displaying some products) that is repeatable. So instead of manually writing the markup to display each product individually, you write it once and get the program to just take some data and generate HTML for you. And instead of rewriting that markup every time anything changes, you just change the data. The data can be a database, or a flat file or whatever. And there isn’t a straightforward demarcation between “static” and “dynamic”: you can have a static site that is just some templates that get built from some data (useful if this was actually a catalogue, rather than a shop) or a fully dynamic site built on top of a database (a necessity if this is actually a shop)
Thank you. I think I see more clearly now. One last question if I may. I can feel my way around front end (html, css, js) but not yet around back end. I read somewhere that php/mysql is more intuitive than node/mongo. Is that so? Which one would you recommend?
I’m not sure about intuitivity, but php + mysql will require learning 2 additional languages (php and sql) which is absolutely fine if you pursue that goal. Node + mongo seems much easier start for someone who knows JS. If I would to choose backend language to learn in 2020 I would go with Go though…
PHP is easier to build out something like you’re talking about. But the major issue being that it’s a different language (well, as above , it’s actually two including SQL). It was designed to provide HTML interfaces for databases, so it works very well for that, and it’s very easy to set up and use. But if you go through the FCC curriculum, then that uses JS and MongoDB, and you’re going to want to know your way around JS for anything web-related, so it’s no bad idea to stick with that.
Just as an aside, SQL databases are much more useful and much more widely used then Mongo (by orders of magnitude), so learning to use them is always likely to be a good idea; PHP, probably less so as time goes on, though it is a very heavily used language