当前位置: 动力学知识库 > 问答 > 编程问答 >

node.js - Should create several similar HTML files or use only one?

问题描述:

I am about to build a social network website. Each user would have their own page. Though the layout would be the same, but the content would be vary according to each user's data.

My question is should I create a new file that contain static HTML for each user, or just use only one file for all users but the replace corresponding data belong to each user when a request comes?

网友答案:

The problem with multiple copys would be that if you want to change one little detail, you would have to change it in all files an that would introduce errors (and is very time consuming anyway).

In the real world people use a Server, with something like PHP, wich has the HTML-Template and adds the user content based on the page.

If possible use "one file"

网友答案:

You should have one file with variables for "user name" or "user avatar url" that you use to generate every user profile page with the data that you have for each user in your database :)

网友答案:

You are building a social website then it should be dynamic. Do NOT think to create a new page for every user, else it would get worst to handle all files. You should have one layout and you can change the data on run-time with programming languages like php or java.

分享给朋友:
您可能感兴趣的文章:
随机阅读: