I recently open-sourced my blog built using Gatsby! This post will walk you through why I chose Gatsby, the Gatsby plugins I used, as well as highlight some features that I have included in my blog.
Why use Gatsby?
One of the biggest pros of Gatsby is its ecosystem. Thereβs an endless number of plugins to add the features you need, as well as plenty of templates to get you started.
Another important benefit is performance. Out of the box, youβre going to get a lightning-fast site, which in turn will boost your SEO. For reference, my site gets a near-perfect Lighthouse score with Gatsby:
Gatsby blogs are built using React and GraphQL, so if you happen to be a React developer (like me) this is also a great plus to be able to build your site with a technology you feel comfortable with.
Using Markdown with Gatsby
I love Markdown, and Gatsby lets me write all of my blog posts with it. Gatsbyβs official blog template is a great way to get started with this.
If youβre looking for something a bit more powerful than Markdown, Gatsby also provides support for MDX. With MDX, youβre able to write your posts in Markdown, and then also add in JSX components wherever you like.
Although my site only uses Markdown at the moment, I based my site off this mdx-blog-starter so that I have the flexibility to add JSX to my posts down the road if I choose.
Gatsby plugins
If youβre looking for a feature to add to your site, chances are there exists a plugin that will do it for you. A few notable mentions:
-
gatsby-plugin-google-analytics
if youβre looking to add Google Analytics to your site -
gatsby-remark-external-links
makes sure that external links in your Markdown will open in a new tab -
gatsby-plugin-feed
for an RSS feed (which comes in handy when you want to cross-post to DEV!) -
gatsby-remark-autolink-headers
will add the ability to link to subheadings on your page (you can see it if you hover over one of the headings on this post)
Social cards with Gatsby
Social cards are the images you see when you share a link to your blog on sites like Twitter or Facebook. This is what the social card looks like for this post:
There are a couple of plugins that will generate social cards for you, however they are slightly limited in their design and functionality. I instead opted to modify a script created by Max Poutord that lets me create a React component for my social card, and take a screenshot of it.
Newsletter sign-up prompt
Everyone recommends that you should have a newsletter, so Iβve added a component to the bottom of each blog post that gives readers the option to subscribe. I decided to go with buttondown.email as it was the cheapest option I could find, compared with some of their competitors.Iβm yet to release my first newsletter, but I am thinking of making it a monthly roundup of my posts and what Iβve been up to. Feel free to subscribe if you are interested!
Web monetization with Gatsby
During DEVβs web monetization hackathon a couple of months back, I wrote a post on how to set up web monetization with Gatsby. Essentially, web monetization means that if people visit my site, and theyβre subscribed to a service like Coil, I will receive a small amount of money (fractions of a cent) depending on the amount of time they visit my site.Itβs super simple to set up. Iβve only made $5 so far, but I think the idea behind it is pretty cool.
Each post links to its Markdown file
Now that my blog is open source, I can give readers the opportunity to make contributions to my site. At the top of each post, I have a link to its Markdown file on Github. If you happen to notice a typo while reading one of my posts, youβre welcome to open a pull request on Github to fix it!
Hosting Gatsby on Netlify
For hosting, I use Netlify. Itβs very user-friendly, and itβs free! Each time I push to my blogβs repository, it will automatically trigger a new deploy and my site will be ready in minutes.
Whatβs next?
Updating my blog has been kind of addictive, and thereβs a couple more features that Iβm planning on adding:
- Better code snippets
- Integration with DEV using its API
I think this blog overhaul has rejuvenated my interest in writing posts, and so Iβm excited to see what the following months will bring. Stay tuned!
Top comments (5)
I loved your website, I have used jekyll before. So I don't know how to post on this site, could you make a tutorial please. I'd really appreciate that.
Thankyou! There are definitely a lot of good tutorials out there already e.g. this one : daveceddia.com/start-blog-gatsby-n...
Thanks alot
Great article Emma ! π΅ Well done, I have enjoyed the reading.
Thanks for reading!