One fine day, i decided to make a new version of my site and thats because of my new acquired knowledge and successful little tests. I have a plan to accomplish this but this project is not time bound like nobody is eagerly waiting for it except me.
The plan is very simple, “I want to build a site” and in the address bar, i don’t want to see .html when the page is displayed. I want to make content and maintain consistent look across the site. Content can be stored in .json or markdown or even better in Firebase storage. Most importantly appearance has to be awesome.
Solutions
There are many solutions to this like .htaccess, but to me better one is running the application written in NodeJS with Express.
To maintain consistency, i can use NodeJS template engines like EJS, PUG, Handlebars, etc…
Data can be retreived from Firebase / Firestore or Firebase storage, think on pricing, coding and how often will you use this.
Awesome appearance. hmmm, get a list of things you want to have and prepare of list of essential things/must have sort of.
Next few months, mostly i have been working on the requirements, you know the The Awesome Appearance, actually was alot occupied at work, so mostly i was just making notes and saving links in Stash. And one fine day, i decided i should put a end to all this and make the site and like all successful Software products, there should be a plan/strategy to do this. Honestly to say, i didn’t go step by step, i was working parallely in all stages at different times like changing designs and steps based on feasibility.
Epiphany Moment. Its going to be a plain content site, nothing else. (PERIOD)
3
Design
You are here, this is the final product. Next 3 stages are repetitive
4
Build
Started to add some content here
5
Test
This is a test till break stage. If it breaks, go back to stage (3)/(4) depending on the issue. If it does not break, then you are in UAT/Pre-PROD zone. Do the final testing. If all OK, move to next stage.
Use gatsby CLI to install the starter template. It will take around 5mins or so to finish(in my system)
Start the template site.
What gatsby develop does is, runs the server in the background, enables useful features like live reloading and Gatsby’s GraphQL to query pages & attributes.
Visit the site http://localhost:8000/ in browser of your choice.
# Starting the custom changes
After seeing the site working. First change we will be making is in gatsby-config.js and i have highlighted the updated lines
Changes to home page
Updating the text in homepage banner. Its in a file called hero.mdx. It needs to be replaced with below content.
Updating the “Projects” section of the homepage which is in the bottom after “Latest Posts”.
Primary Content
Primary are contents are pages which appears in the page header. For this site, i have decided to have below pages, for now
bio - Possibly going to be a long resume
blog - This is where the articles will be listed.
TIL(Today i learned) - Snippets, life lessons, plans, ideas, todos, bucket list, etc.
music - My Fav music from Spotify.
iRevere - People, whom i followed/follow and get inspiration from. According to me they are the best in what they do.
Steps to add new primary content
Create a new folder inside content/pages like bio, blog, TIL, music and irevere
Create a new index.mdx file
In index.mdx write your frontmatter(title, slug) and content
Adding new post
Posts are blog posts (or) articles and they can be added by creating folders/files inside content/posts folder.
Create a new folder inside content/posts
Create a new index.mdx file
In index.mdx write your frontmatter(title, date, description, tags and slug) and content below it
# Test
Testing is quite simple. All you need to do is to type the below command, this will start a development server in your machine and watch for changes and refresh the site(just like nodemon)
Below will be the output of the above command
You can browse your test site in http://localhost:8000/
Sometimes during testing, thing might not work as expected, during those times, Keep calm and rungatsby clean and then gatsby develop again, to see if this worked.
# Advantages / Disadvantages of this theme
Advantages
Code block - You can highlight specific code lines in a code block, turn on/off line numbers, can mention programming language name and title
Blog page will be updated with the list of all the posts in descending order. If post doesn’t appear, basically means that .mdx file has issues. Check the VSCode console for any error messages.
Has Dark mode
Blog posts have tags
Images get optimized properly and images have shadow glowing effect
Disadvantages
Gatsby Markdown MDX - Regular markdown supports HTML codes but MDX doesn’t. Eg:- line breaks <br>
Making custom changes to the code, you have to be an expert going through codes in node_modules folder and sub-folders.
Gatsby Shadowing, sometimes it works and sometimes it doesn’t. Its a great feature, by the way.
# Conclusion
Does it fit the purpose ?
Yes. I wanted a simple site to dump my learnings, an online archive, wanted it to be fast, responsive with tagging & code highlighting capabilities for posts. This particular gatsby theme has all of it and more, which i am still exploring.