Adding Treehouse Badges Widget to Site
Tags: javascript, treehouse
Published: 2019-02-13 07:22:49

---
title: Adding Treehouse Badges Widget to Site
published: true
description: Want to add your Treehouse Badges to your non-WordPress site?
tags: javascript, treehouse
canonical_url: https://www.carmenwright.design/blog/adding-treehouse-badges
---

*I originally posted this article on April 21, 2017 on the Codette Club's [Medium](https://medium.com/codetteclub/adding-treehouse-badges-widget-to-site-bea56078158) account*

Ever since my local library provided access to [Treehouse](https://teamtreehouse.com/home) courses for free, I’ve jumped on it and haven’t let go. I love the structure of the courses and the badge you receive when you complete courses are the tangible proof that makes me excited about learning.

![image of the Treehouse logo](https://cdn-images-1.medium.com/max/800/1*tsYo6yPbQw95oA_1FJzlHw.png)

The downside of the Treehouse badge system is there is no clear way to display the achievements on a non-WordPress website. After searching for some time for a way to display them, I found Riley Hilliard’s [Treehouse Widget](http://rileyh.com/treehouse-badges-widget). I loved the honeycomb effect of the badges and how he broke down the code so you can customize it however you want (yay for comments!).

The downside of this widget is no way to insert it into your site. I followed the instructions with the [Report Card](http://reportcard.rileyh.com/), but those didn’t work and I’m not a fan of the Report Card widget.

It took a few days and several changes to the code, but I finally figured it out. With some modification to make it better for mobile devices, you can have your own Treehouse badge widget in no time.

** Fork the original Treehouse widget on [CodePen]**(https://codepen.io/rileyhilliard/pen/BovGu).
**NOTE**: I’ve tried to copy and paste into a new Pen, but it didn’t work.

![image of where to fork the CodePen](https://cdn-images-1.medium.com/max/800/1*BbM1-8xvSMsNLQkv8-mwQw.png)

**Read through the code in the HTML, CSS, and JS panels.** You’ll want to replace the username with the one that is connected to your Treehouse account.

![image of where to replace the username](https://cdn-images-1.medium.com/max/800/1*cGwk0efCFJ_KU20jdiZUnw.png)

**Export the CodePen project** or you can copy and paste directly from the project. If you choose to do this, you’ll need to create a new .js file.

![image of the export button](https://cdn-images-1.medium.com/max/800/1*U0IJKVm_StLc8aBdvKKH3g.png)

**Transfer the .js file to your project’s JS folder.**

In the HTML, **create a new .container div** to hold your new widget code. Paste the widget code int that div.

For my code, I called the div .row because I was working in Bootstrap and needed to add a .row anyway.

![image of where to create the .row div](https://cdn-images-1.medium.com/max/800/1*FMypMMB2ogH9VVwtabYBVg.png)

**Copy and paste the CSS code into your main CSS file.**

**Add JS script link to bottom of HTML right before you close the <body> tag.**

![image of where to place the JavaScript link](https://cdn-images-1.medium.com/max/800/1*iZ8LFSlfp1DYkWaLK3f4Sw.png)

At this point, **the JS file should have linked**.

I tried to add the JS script in the <head> and before all the other JS script. It didn’t work. Since my knowledge of JavaScript is still limited, I’m putting this step here in case another newbie comes across this.

All that remains is **modifying the CSS** to make sure the code appears spaced out for mobile devices. When modifying the CSS, I found the mobile size not as uniform as the desktop version.

![image of how the Treehouse badges should appear](https://cdn-images-1.medium.com/max/800/1*MCqZTC0Qfo8-4os3c1ulDA.png)

I modified a bit and found I still didn’t like it. I stuck the original code back in and figured it looked wonky because of the number of badges I have I’ll try it again when I have more.

*I want to give a big thank you to [Riley Hilliard](https://twitter.com/rileyhSD) for building the Treehouse widget in the first place.*