Introduction and Getting Started with GatsbyJS

JavaScript

gatsby

Introduction and Getting Started with GatsbyJS

GatsbyJS is a free, open-source React-based static site generator.  It is specifically built with performance in mind and delivers 2-3x fast results as compared to same kind of applications built using different tools.

Pre-Requisites:

Before you start working with Gatsby, it’s better to have some prior knowledge of JavaScript, ES6, React and obviously HTML and CSS.

Misconceptions about Gatsby:

It is a general misconception about Gatsby which may be due to the slogan that it’s a static site generator which makes people think, what if we have to use dynamic content? Brace yourselves, everyone, because the answer is YES! You can use dynamic content without any problem in Gatsby.

Get Started:

So now as we know what Gatsby is, let’s get started:

First of all, you should have the latest version of NodeJS installed on your system. If you don’t have Node installed, you can visit the NodeJS website (link provided at the bottom) to install Node.

Now open the terminal and install Gatsby CLI:

npm install -g gatsby-cli

This command installs Gatsby CLI globally on your system.

Gatsby CLI will help us use specific functionality like creating a new website, running development server and creating production build, etc.

Now let’s create a new project using CLI. Run the following command in terminal:

gatsby new gatsby-site-name

This command will generate a new website for us which is ready to run (no configuration required whatsoever) HURRAAAYYY!

Running Development Server:

In order to start the development server, use the following command in terminal:

gatsby develop

It will start a hot-reloading development environment on port 8000. You can access the website using URL: localhost:8000

Project Breakup:

By now you have installed and seen the running demo website. Time to explore the code doesn’t you think! Open project in your favorite text editor, I prefer Visual Studio Code, but you can choose whichever code editor you feel comfortable with.

Once you will open the project on the code editor, you will see the following project structure:

|-- / node_modules
|-- /src
    |-- / components
    |-- Images
    |-- /pages
|-- gatsby-config.js
|-- gatsby-node.js
|-- gatsby-ssr.js
|-- gatsby-browser.js
|-- package.json

Notable files/folders and their definitions:

  • node_modules — contains all of the installed modules and packages
  • gatsby-config.js — configure options for a Gatsby site, with metadata for the project title, description, plugins, etc.
  • gatsby-node.js — implement Gatsby’s Node.js APIs to customize and extend default settings affecting the build process
  • gatsby-browser.js — customize and extend default settings affecting the browser, using Gatsby’s browser APIs
  • gatsby-ssr.js — use Gatsby’s server-side rendering APIs to customize default settings affecting server-side rendering
  • src/components — this folder contains the components and some essential components that you need are created by default here like header and layout.
  • src/images — contains images for your website
  • src/pages — website pages will reside in this folder

Pages, Routing and Internal page linking:

The most important question that comes to our mind now is how pages and routing work.

When you create a new file under the src/pages folder, file name automatically becomes the path of that page. For example, if the file name is “test_page”, page route will become “localhost:8000/test_page”.

Now next question that comes to our mind is how internal page links work. Although you can use an HTML anchor tag if you have some prior knowledge of React, your answer should be a big NO.  If you will use anchor tag, it will destroy the whole purpose of Single Page Application (SPA) as it will reload the page.

Gatsby offers us a very elegant solution for page linking. It has a built-in <Link> component which enables linking internal pages and offers a performance boost by using the preloading features. This means if you are on a certain page that contains the Link tag, Gatsby will preload the page defined in that tag for a smooth user experience.

Example

import React from "react"
import { Link } from "gatsby"

const Page = () => (
<div>
    <p>
      Check out my <Link to="/blog">blog</Link>!
    </p>

    <p>
      {/* Note that external links still use `a` tags. */}
      Follow me on <a href="https://twitter.com/gatsbyjs">Twitter</a>!
    </p>
</div>
)

In the example mentioned above, you can see the basic usage of Link tag. In order to use it, you must import the Link component and in the link tag, you must define “to” attribute for the destination link. Link tag offers tons of cool features too like active link class and active link styles etc, but as the scope of this article is just an intro and is meant for beginners so we are not going to discuss them here. You can check out the official Gatsby documentation for more details.

Gatsby Plugins:

Gatsby is designed to be extensible so it offers tons of cool features in the form of plugins. The advantage of using Gatsby plugins is that they offer prepackaged integration into the core Gatsby APIs to save you time and energy, with minimal configuration.

You can install these plugins (https://www.gatsbyjs.org/plugins/) as node packages and add functionality to your website.

Installation and Configuration:

To install the Gatsby plugin, just run the nom install command with the name of the plugin:

npm install --save gatsby-transformer-json

In order to make the plugin work, you also have to add the plugin name in a gatsby-config.js file in plugins array.

module.exports = {

  plugins: [`gatsby-transformer-json`],

}

If the plugin takes options, you can also define them here too.

Using Third-Party Plugins:

Plugins offered by Gatsby are just an added feature, it doesn’t mean that it is mandatory only to use these plugins. If you want to install other third party plugins/packages like Axios, lodash, etc, you can install and use them too.

Generating files for deployment on the server:

Once your website is created, obviously you want to deploy it on the server. Run the following command in terminal:

gatsby build

Once done, you will find all the files required for deployment in the public directory at the root of the project.

Important Links:

https://www.gatsbyjs.org/

https://www.gatsbyjs.org/docs

https://www.gatsbyjs.org/plugins/

https://nodejs.org/en/download/

 

javascript

Stop Struggling with JavaScript

JavaScript

Are you a front-end developer who is struggling to truly understand JavaScript? Or maybe you are UI/UX designer working with a front-end developer who is an advanced JavaScript developer. Regardless where you are at in your professional web dev/design career, JavaScript is an important language to at least have some basic understanding of.

I have even avoided JavaScript for a portion of my web career just because I was either assigned to projects that did not require my full attention to the language or was able to work with other front end developers who were able to assist me with that portion of the project. I have even written about JavaScript and other web anxiety.

Beyond HTML, CSS, PHP and WordPress

But recently I had to put my foot down and fully indulge in the JavaScript language because I wanted to advance my career beyond HTML, CSS, PHP, and WordPress.  I have spent indulging in physical books, e-books, audiobooks, videos, and online courses. They say that “10,000 hours” in anything makes you an expert and that is what I set out to do.  Here’s what I have spent doing to truly understand the JavaScript and break any fear of the language:

JavaScript Books:

Below is a list of books that have helped me truly understanding programming and the JavaScript language, I especially recommend that You Don’t JS Series By Kyle Simpson. I personally enjoyed the hard copies of the book because I enjoy highlighted and making physical notes in the book but there are of course free digital copies on github.

JavaScript Audiobooks:

I have a long commute to and from work some days. So beyond podcasts, I enjoy audiobooks too. Now I know what you may be thinking? JavaScript audiobooks? How? Why? It’s not all about writing code, all though that is the fun part, sometimes. It’s also about understanding the overall concept of it.

These are just some of the many ways I am improving my JavaScript skills. So, whatever it’s you are afraid to learn or don’t think you can’t learn, just consume yourself in for 10,000 hours and eventually you will get it.

Want to make six figures? Learn to be JavaScript Developer

Technology

There are thousands of JavaScripts freely available for downloading. These range from Drop Down menus to Snow Effects, from Mouse-over Effects to Digital Real-Time Clocks.

JavaScript is useful for introducing limited animation to your web pages without the download times associated with Flash animations. Your page tracking and Google Adsense tracking also use JavaScript.

People see JavaScript programming as a new and highly paid career. Universities supply the courses because the demand is there and it’s a good way for the university to make money. As these qualified programmers come onto the jobs market, the number of programmers is going to exceed the number of vacancies and salaries will fall.

When companies can outsource their programming needs to low cost countries like India and China, they are unlikely to want very many highly paid programmers on their rolls.

If you do learn JavaScript you can earn money on one of the freelancing sites, by bidding on various projects. Be aware that you will not be able to compete on price with programmers from India or China, to compete on quality and completion times. The reputation you establish early on will stay with you for a long time, so make sure it is an impeccable one.

JavaScript does have some disadvantages. It works differently on different browsers and it increases the download time of your pages.

Against these disadvantages are its advantages. There are sites where you can download scripts for free and many sites where you can learn at least the rudiments of JavaScript programming without paying a cent.

JavaScript and other Web Anxiety

JavaScript and other Web Anxiety

Technology

I recently came across this excellent video called “Full Stack Anxiety” by Joel Califa with this related article by @FirstMark and it got me thinking about my current situation as this hybrid UI/UX designer and front-web developer.

First, a little background on my web career for context

I have been building digital deliverables for the web since 2005, and in the beginning, I struggled with HTML and CSS and was more of the Adobe Creative Suite guy using Photoshop and InDesign to design print materials. Later on, continued to traverse the Adobe Creative Suite with Flash and Dreamweaver (actually when I started using Flash and Dreamweaver they were still own by Macromedia). Built a few great portfolios in Flash and some okay websites in Dreamweaver utilizing templates.

Hit a few bumps in the road at the beginning of my career working for some not so great freelance gigs and contract jobs, but all of them a learning experience making me a better at what I choose to focus on and find my niche in the web world.

Between 2006 and 2007 I began to understand HTML and CSS and was able to build websites utilizing Photoshop, NotePad++ and your traditional shared hosting provider, uploading files via FTP.  I also was able to implement things like JavaScript and jQuery but never without reference; I could never write JavaScript from scratch as I did with HTML and CSS. There was a lot of copying and pasting happening with JavaScript.

Then I discovered WordPress, and it opened a whole other realm of opportunities for me.  I felt limitless with WordPress and still do today. But what I was finding utilizing the framework like WordPress was that I was missing out on the opportunity for what I  would consider “hardcore web programming,” for example building a PHP or JavaScript web app from scratch. And doing that hardcore web programming with all the fancy compilers and make tools you find today. For example Gulp, Grunt, WebPack LESS, and or SASS.

Also felt like I missed out on genuinely understanding JavaScript and now not having a keen understanding of JavaScript background leaves you not worthy of many UI developer jobs. Or even worst you try to take a UI developer job to learn JavaScript and all the cool new tools, but the current web-devs are a bunch of pompous, egotistical assholes. And if you don’t operate at their speed your, then you are an idiot! “Look at how fast I can use the command line.”

Sorry had to vent there, let’s get back on track.

What to focus on next for my web career?

I have held a multitude of positions everything from graphic designer to web developer to the more recently UX designer and UI engineer. To me, they are just titles. Why? Fundamentally I approach all my jobs with a similar mindset, get presented with a problem/task and do everything in your power and knowledge to solve that problem even if not knowing the proper syntax or methodology to explain it. How to explain it? Utilizing your past experiences,  online resources, and communities.

Over the years you gather the necessary and experience and knowledge to take with you for your next adventure (job/gig). But sometimes that only gets you so far. Questions I ask myself today

  • Should I niche down? – For example be purely a WordPress Developer.
  • Should I get better at JavaScript and pick up a framework like React.js? – Probably should
  • Should I focus more on product design and management? – Maybe one day I could be a product manager and not worry about coding every again.
  • Should I focus on project management? – Maybe one day I could be a project manager and never worry about coding again.
  • Do I continue to be a jack of all trades and master none? – Not likely a good idea.

Hence, you can see where the anxiety comes in to be being a web-dev hybrid purple squirrel thingy.

But thanks to the excellent video and article by Joel he does give us some impressive outlooks on what to focus on (note this our my takeaways):

Be happy with your career and what you decide to do

Currently, I am satisfied working as front-end web developer/graphic designer typically in marketing departments utilizing tools like WordPress, Photoshop, Moz, Hubspot, Google Analytics and Hootsuite to deliver compelling digital solutions and custom WordPress sites that drive leads to convert.

Where do I want to be eventually, maybe? I may see myself as a creative director, product manager or even a director of development/IT. But who knows where the road will take me. For now, I keep gathering experience and knowledge with me with each job and moving forward.

Since I feel confident in the UX design process and am proficient in Photoshop, rapid prototyping, etc. I feel like I want to focus on learning hardcore JavaScript development. Why? I think it’s imperative for me to stay relevant in the front-end web development world. Plus I feel most developers get paid more than designers in some cases*.

*Of course, this is based on industry, company, location and whole other bunch of factors. But currently I see developers getting paid more in my region and more opportunities for developers then I do designers. 

Stop being a jack of all trades and master none

So to paraphrase Joel,  “Stop chasing the trends” – You don’t have to learn the latest and greatest JavaScript framework. But be aware of those frameworks and maybe try one out but do what you are good at for now and keep learning.

So thanks Joel for putting things in perspective it helps. Until next time, Godspeed.

6 Basic Website Design Tips

6 Basic Website Design Tips

UX Design

6 Simple website design tips

1. Use CSS (cascading attraction sheets).

If you follow through not apperceive CSS, ferret out it. CSS allows you to maintain the formatting of your town (e.g. the color or size of a blonde of text) on a disparate at variance page – a CSS document. Thus, with CSS you can impinge the formatting of a common-element by simply updating one piece of code on one page, rather than updating all the pages of your site. For example, if you want to change the background color of your website, you could just change your one CSS sheet and your entire website’s background color would change. Another great aspect of CSS is that you can use it to set the default properties of HTML tags. This can be used to counter browser compatibility problem – that different browser (e.g. Internet Explorer, Google Chrome, etc.) use different default settings.

2. Test your website in all browsers.

Just now your website displays a singular rubric in one browser, doesn’t cruel it commit an act that disposal in an also browser. You should permit that your website displays properly in all of the primary following browsers: Mozilla Firefox, Internet Explorer, and Google Chrome, and Opera.

3. Use opens source scripts if you need to plunge into an energizing website.

Even if you undergo influential languages (such as JavaScript, PHP, and MySQL) absolutely enough to lead your receive software and features, you do not want to do that if you are a beginner. There’s no reason to create your own dynamic scripts (e.g. shopping carts, chat-rooms, etc.) if you can find full-functioning customizable open source scripts. A great benefit of this method is that the customization options will separate the code that changes your website’s look and feel from the functioning code. If you design the code yourself, you’ll be tempted to mix the look and feel with the functioning aspects. So, if later you want to update the look and feel, you’ll have to dig through the long software scripts. If you’re going to be using freeware or any other code that you didn’t design yourself, you should still be familiar with that language.

4. Don’t benediction for free or tasteless web-hosting.

Okay, this isn’t necessarily a star tip. However, hosting is the twin to design. Free hosts may emit your website with awkward ads. So, you won’t be adequate to task your region as is. Also, free and cheap hosts often don’t support dynamic websites. Unless your website is supposed to be a joke, don’t use a free host.

5. Don’t compose your email superscription on your website.

If you have a mailing directions that your customers can betterment to discharge you or your business, make public that on your website. Website’s with a phone embrace or mailing directions loom much more reliable and honest than websites without contact information. However, don’t publish your email address, because spammers will use web-crawlers will to pick it up. Instead, design a form on your website that customers can use to send messages or questions without giving your email address.

6. Take it slow.

Unfortunately, the own disposal to alter to a brilliant designer is considering experience, but your vim can’t render sloppy pages. Don’t go to generate confused and dynamic websites without the ability. If you try to design a code, but find it hard and the code begins to come out sloppy, don’t hesitate to just throw it out. It’s better to have a simple, sleek, and functional website than to have a complex, sloppy, dysfunctional website.