I'm creating a blog engine as a learning exercise and one particular problem has me stumped. I'm wondering how are blog posts created in say a blog engine such as Wordpress? I'm thinking there are 2 ways you can do this:
1) Creating a new blog post called 'testPost' creates a new HTML page called www.myblog.com/testPost.html. So for each new blog post you save a new HTML page to the server. This method seems inefficient. A blog can have hundreds of blog posts, which means you would have to create hundreds of HTML pages. I don't think I want to use this method.
2) You have a generic blog post page whose data is rendered according to the blog post you are trying to access. For example if I created 'testPostOne' the generic blog post page would be filled with testPostOne's data and URL, if I created 'testPostTwo' then the generic page would render testPostTwo's respective contents and so on.
But using this method brings its own problems. For example how would you link to a page that doesn't actually exist? Linking to http://www.myblog.com/testPostOne.html would not work.
These are the two ways I could come up with to solve this problem. Maybe there is another way of doing this, I'm not sure. Please feel free to recommend a better way of solving this problem if you know of one.
Basically, I want to be able to have a nicely formatted url for each blog post without having to create a new HTML page on the server for each one.
EDIT: I might add that I'm using ASP.NET to do this so any methods available via this framework would be helpful