Question

I've been working on my own website for a while and wanted to go ahead and make my own blog type section where I can post things. I've managed to get that done but would like to have an automatically updating 'Recent Posts' list in the sidebar instead of having to manually update the post names and links every time I go to make a new post. Here is what my sidebar looks like right now:

<aside id="sidebar">
    <div id="recent">
        <p>Recent Posts</p>
        <h3><a href="articles/first_post_20140124.html" title="First Post">First Post</a></h3>
        <h3><a href="articles/second_post_20140124.html" title="Second Post">Second Post</a></h3>
    </div>
</aside>

So what I'm assuming I need to do is have some code that looks in the '/articles/' directory, finds the most recent post (all posts are timestamped) and then adds in the file path to the anchor?
I'm pretty new to coding things from scratch as I'm normally on the design side of things, so any help would be much appreciated.

Was it helpful?

Solution

In order to access the file system (to find your posts and determine which are most recent) you will probably need some kind of server-side technology. Javascript (and of course HTML5) for example runs on the client's browser and is not touching your server's file-system.

You have to look at what kind of server-side technologies are available to you. For example, can you use PHP, ASP.net, etc? Take a look at where your site is hosted and see what you can find, do a little research, then edit your question accordingly.

Depending on how set you are on this feature this may be more trouble to set up than it's worth but in terms of difficulty, it is not hard to do, and it is a good way to learn the basics of programming.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top