How do large websites manage so many webpages?

Viewed 283

How do large websites create so many webpages? Do they make a new .html file everytime they want a new page on their website? I read something about how links on these large websites arn't really pages but created in a database. If so how can I make a website with a database for webpages. Im trying to make a website that lets users download stuff but that would be a lot of .html files so whats the best way?

3 Answers

Templating.

Depending on the type of page you want to serve: home, section, article, etc... the server knows how to respond to different page requests.

If the header code and footer code repeats over multiple pages you include this partials in those different templates

Since your question is focused on websites havig N pages say for example a website with many products, the design for a product looks the same, so all you need is to instruct the server how to handle a specific route:

example.com

head  
welcome  
footer  

example.com/products

head 
allProducts  (pagination etc) 
footer

example.com/products/101

head  
product<id>  
footer

here the server detects that a request for a route has some ID after /products/, your backend logic should use the article (product template), go grab that product ID from the database (image, images, title, description, content, price etc) and populate such single template with that data - and send it to the client.

That way no matter how many products (pages) you have, you need only one HTML template.

SPA (Single Page App) follows the same principle, just updating the content with AJAX (no page refresh)

Edit:

See Roko C. Buljan's answer above. It answers it more eloquently.

In the future, I will focus on answering the actual question being asked.

I'm new here.

Great question. The requirements for the website you're trying to make moves past what static .html pages can provide.

Although from what I understand you are trying to build might be complicated to build from the ground up, as David mentioned frameworks would be the way to go. for example a nodejs/vuejs app (website) built with a 'stack' of programming tools present one 'view' (page) and change the contents of the page based on what actions the user takes.

Here are tutorials on:

  • nodejs - the server.
  • vuejs - the view and brains of your app.
  • MongoDB - your database you referred to for stack style apps.

These 'stack' types of apps (websites) cut down on all the document transfers of .html pages for the user to wait for and really increases speed and usability.

That depends on so much stuff ...

Sure you could have a separate html file for every page. Especially if you want to not be javascript dependent. Routing then happens trough the folder structure and you access every page separately by making a GET request on the specified address.

That's old-school. I think that kinda changed with PHP & Wordpress where a page skeleton is fed with data coming from the db and then that is displayed to the user.

Nowadays your backend feeds data to your frontend, usually through json format. So the page you are visiting is the front end of a web app. The backend waits for a request which it then handles by serving the right data, if authentification is OK. All that is done usually with PHP or any other backend language and using a DB, SQL or NoSQL.

The front end is only one tiny html page with nice javascript which just replaces any element in the page like you want depending on what the dev' decided to.

That's Angular or Vue.js

Related