Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Gabriel Ward
Gabriel Ward
20,222 Points

Node.js and blog

I'm currently taking the 'Build a simple website with Node.js' course, and I'm wondering, would it be possible to build a simple blog system with Node.js?

4 Answers

Kevin Korte
Kevin Korte
28,148 Points

Absolutely! And someone's already done it

https://hexo.io/

Gabriel Ward
Gabriel Ward
20,222 Points

Hi Kevin,

Ok thanks. I guess programming is all about building things, so I kind of want to get better at programming and have something to show on say, GitHub by building my own blogging platform.

I am actually having a bit of a problem, you can see my question about it here:

https://teamtreehouse.com/community/workspace-unavailable-3

I'd be grateful if you have any suggestions/solutions!

jason chan
jason chan
31,009 Points

I see that ejs. LOLs.

jason chan
jason chan
31,009 Points

Yes.

npm install express
npm install body-parser
npm install mongoose
npm install method-override
npm install express-sanitizer
npm install ejs

Your going to need a rest api schema though. I prefer ejs for templating engine very similar to php

<% include ./partials/header %>
<div class="ui main text container segment" style='margin-top: 7em;'>
    <div class="ui huge header">New Blog</div>
    <form class='ui form' action='/blogs' method='POST'>
        <div class="field">
            <label for="">Title</label>
            <input type="text" name="blog[title]" placeholder='title'/>
        </div>
        <div class="field">
            <label for="">Image</label>
            <input type="text" name="blog[image]" placeholder='image' />
        </div>
        <div class="field">
            <label for="">Blog Post</label>
            <textarea name='blog[body]'></textarea>
        </div>
        <input class="ui red basic button" type="submit" value="Submit"/>
    </form>
</div>
<% include ./partials/footer %>

<%= to print output %> <% no output hidden js script serverside %>

Gabriel Ward
Gabriel Ward
20,222 Points

Hi Jason,

Are your replies here in relation to my question above?

jason chan
jason chan
31,009 Points

Yes, those are packages i used to build my node js blog. I built it from scratch though with rest api. LOLs.

Gabriel Ward
Gabriel Ward
20,222 Points

cool. What's your blog website, I'd love to check it out.

Have you taken the Express.js course, that is part of the Full Stack Javascript Course? It looks like that is about how to build a blog.

jason chan
jason chan
31,009 Points

it's on c9 I haven't even deployed it yet or put on github. It's very basic. Hopefully, in a month I'll have it up on heroku. Still easier to skin that wordpress jmo. If you go the express route. ejs for me better than jade. Teamtreehouse teaches jade. it's very space sensitive. If you come from python. Jade will not be as bad.

Gabriel Ward
Gabriel Ward
20,222 Points

Hey, cool.

I'm trying to go through the npm course now, and having trouble installing bcyrpt into a folder on my desktop :(