— web-development, gatsbyjs — 3 min read
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
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.
This is the thing, THE SDLC
N | Stages | Activity |
---|---|---|
1 | Plan | Collectors item / All amazing fancy stuff |
2 | Define | 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. |
6 | Deploy | Truly a ninja moment, nobody knows that this site exists, but it does |
7 | Maintenance | Add more content |
Install NodeJS
Install Gatsby CLI
npm install -g gatsby-cli
Go to the github site Gatsby Starter: Minimal Blog
Open your VS Code and create a new folder
mkdir lupincd lupin
Use gatsby CLI to install the starter template. It will take around 5mins or so to finish(in my system)
gatsby new bdv3g4 https://github.com/LekoArts/gatsby-starter-minimal-blog-- orgit clone https://github.com/LekoArts/gatsby-starter-minimal-blogcd gatsby-starter-minimal-blog-- or git clone https://github.com/LekoArts/gatsby-starter-minimal-blog bdv3g4cd bdv3g4
-- If you use npm 7 or above use the `--legacy-peer-deps` flagnpm install --legacy-peer-deps
Start the template site.
gatsby develop --verbose
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.
After seeing the site working. First change we will be making is in gatsby-config.js
and i have highlighted the updated lines
1require(`dotenv`).config()2
3const shouldAnalyseBundle = process.env.ANALYSE_BUNDLE4// const googleAnalyticsTrackingId = process.env.GOOGLE_ANALYTICS_ID5
6module.exports = {7 siteMetadata: {8 siteTitle: `bobby_dreamer`, 9 siteTitleAlt: `BobbyDreamer - Works of Sushanth Bobby Lloyds`,10 siteHeadline: `Personal website of Sushanth Bobby Lloyds`,11 siteUrl: `https://www.bobbydreamer.com`,12 siteDescription: `Sushanth Bobby Lloyds. Programming. Experiments. Wealth. Music. Bio.`,13 author: `Sushanth Bobby Lloyds`, 14 },15 plugins: [16 {17 resolve: `@lekoarts/gatsby-theme-minimal-blog`,18 // See the theme's README for all available options19 options: {20 navigation: [21 {22 title: `about_me`,23 slug: `/bio`,24 }, 25 {26 title: `blog`,27 slug: `/blog`,28 },29 {30 title: `T.I.L`,31 slug: `/til`,32 },33 {34 title: `music`,35 slug: `/music`,36 },37 {38 title: `iRevere`,39 slug: `/irevere`,40 },41 ],42 externalLinks: [43 {44 name: `Github`,45 url: `https://github.com/bobbydreamer`,46 },47 {48 name: `LinkedIn`,49 url: `https://www.linkedin.com/in/sushanth-bobby-lloyds/`,50 },51 ],52 },53 },54 {55 resolve: `gatsby-omni-font-loader`,56 options: {57 enableListener: true,58 preconnect: [`https://fonts.gstatic.com`],59 interval: 300,60 timeout: 30000,61 // If you plan on changing the font you'll also need to adjust the Theme UI config to edit the CSS62 // See: https://github.com/LekoArts/gatsby-themes/tree/master/examples/minimal-blog#changing-your-fonts63 web: [64 {65 name: `IBM Plex Sans`,66 file: `https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&display=swap`,67 },68 ],69 },70 },71 `gatsby-plugin-sitemap`,72 {73 resolve: `gatsby-plugin-manifest`,74 options: {75 name: `BobbyDreamer - Works of Sushanth Bobby Lloyds`,76 short_name: `bobby|dreamer`,77 description: `Sushanth Bobby Lloyds. Programming. Experiments. Wealth. Music. Bio.`,78 start_url: `/`,79 background_color: `#fff`,80 theme_color: `#6B46C1`,81 display: `standalone`,82 icons: [83 {84 src: `/favicon-32x32`,85 sizes: `32x32`,86 type: `image/png`,87 },88 {89 src: `/android-chrome-192x192.png`,90 sizes: `192x192`,91 type: `image/png`,92 },93 {94 src: `/android-chrome-512x512.png`,95 sizes: `512x512`,96 type: `image/png`,97 },98 ],99 }, 100 },101 `gatsby-plugin-offline`,102 `gatsby-plugin-gatsby-cloud`,103 `gatsby-plugin-netlify`,104 {105 resolve: `gatsby-plugin-feed`,106 options: {107 query: `108 {109 site {110 siteMetadata {111 title: siteTitle112 description: siteDescription113 siteUrl114 site_url: siteUrl115 }116 }117 }118 `,119 feeds: [120 {121 serialize: ({ query: { site, allPost } }) =>122 allPost.nodes.map((post) => {123 const url = site.siteMetadata.siteUrl + post.slug124 const content = `<p>${post.excerpt}</p><div style="margin-top: 50px; font-style: italic;"><strong><a href="${url}">Keep reading</a>.</strong></div><br /> <br />`125
126 return {127 title: post.title,128 date: post.date,129 excerpt: post.excerpt,130 url,131 guid: url,132 custom_elements: [{ "content:encoded": content }],133 }134 }),135 query: `136 {137 allPost(sort: { fields: date, order: DESC }) {138 nodes {139 title140 date(formatString: "MMMM D, YYYY")141 excerpt142 slug143 }144 }145 }146 `,147 output: `rss.xml`,148 title: `Minimal Blog - @lekoarts/gatsby-theme-minimal-blog`,149 },150 ],151 },152 },153 shouldAnalyseBundle && {154 resolve: `gatsby-plugin-webpack-bundle-analyser-v2`,155 options: {156 analyzerMode: `static`,157 reportFilename: `_bundle.html`,158 openAnalyzer: false,159 },160 },161 {162 resolve: `gatsby-plugin-google-gtag`,163 options: {164 // You can add multiple tracking ids and a pageview event will be fired for all of them.165 trackingIds: [166 "G-6X2JSPJ1WR", // Google Analytics167 ],168 // This object is used for configuration specific to this plugin169 pluginConfig: {170 // Puts tracking script in the head instead of the body171 head: true,172 },173 },174 }, 175 ].filter(Boolean),176}
Updating the text in homepage banner. Its in a file called hero.mdx
. It needs to be replaced with below content.
1<Text sx={{ fontSize: [3, 4, 5], fontWeight: `bold`, color: `heading` }}>2 Hello, I am Sushanth.3</Text>4
5Welcome to my site. 6
7I am a mainframe Db2 DBA. Yep, mainframe is still there and as usual its highly scalable, highly available and highly secured. 8
9If you don't know what mainframe is, you should see [this](https://www.youtube.com/watch?v=ar0xLps7WSY), this is how our work environment looks like. 10
11[This](../hello-world) site is my sandbox, probably will contain collection of my unorganized programming notes, things i learned doing some home projects, fav. music, self development, notes taken while watching youtube videos, etc., more or less. 12
13**Thanks**
Updating the "Projects" section of the homepage which is in the bottom after "Latest Posts".
1<Title text="Home Works" />2
3- [Db2 Notes](../105-db2-notes)4- [Working the djinn](../42-working-the-djinn)5- [Quest for Wealth - Value Investor Education](../40-wealth-education)6- [Side projects](../36-side-projects)7- [Notes from Tedx](../37-tedx)8- [Site Reliability Engineering](../53-sre-references)9- [Stock market terms](../112-stock-market-terms)10- [Shortcuts and commands](../74-shortcuts-and-commands)
Primary are contents are pages which appears in the page header. For this site, i have decided to have below pages, for now
Steps to add new primary content
content/pages
like bio, blog, TIL, music and irevereindex.mdx
file
index.mdx
write your frontmatter(title, slug) and content
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
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)
1gatsby develop --verbose
Below will be the output of the above command
1PS D:\BigData\08. HTML\Gatsby\lupin\bdv2> gatsby develop2success open and validate gatsby-configs - 0.271s3success load plugins - 4.072s4success onPreInit - 0.030s5success initialize cache - 0.040s6success copy gatsby files - 0.275s7success onPreBootstrap - 0.039s8success createSchemaCustomization - 0.024s9success source and transform nodes - 1.319s10success building schema - 1.080s11success createPages - 0.280s12success createPagesStatefully - 0.237s13success onPreExtractQueries - 0.015s14success update schema - 0.101s 15success extract queries from components - 1.142s16success write out requires - 0.460s17success write out redirect data - 0.029s18success Build manifest and related icons - 0.027s19success onPostBootstrap - 0.104s20⠀21info bootstrap finished - 18.945 s22⠀23success run queries - 0.183s - 3/3 16.38/s24warn "typescript" is not installed. Builtin ESLint won't be working on typescript files.25⠀26You can now view bobby_dreamer in the browser.27⠀28 http://localhost:8000/29⠀30View GraphiQL, an in-browser IDE, to explore your site's data and schema31⠀32 http://localhost:8000/___graphql33⠀34Note that the development build is not optimized.35To create a production build, use gatsby build36⠀37success Building development bundle - 13.618s
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 run gatsby clean
and then gatsby develop
again, to see if this worked.
1PS D:\BigData\08. HTML\Gatsby\lupin\bdv2> gatsby clean2info Deleting .cache, public3info Successfully deleted directories
Advantages
Disadvantages
<br>
node_modules
folder and sub-folders. 1@lekoarts\gatsby-theme-minimal-blog-core2@lekoarts\gatsby-theme-minimal-blog
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.
Thank you very much for reading the post!