GithubHelp home page GithubHelp logo

belgijski-ovcar-gatsby's Introduction

Belgijski Ovcar (Gatsby)

Netlify Status

Modernizing a very old website using a stack that revolves around Gatsby, React and Contentful as headless CMS.

https://www.belgijskiovcar.com


⚗️ Technology

JAMstack is an approach to frontend web development (the construction of content and interfaces that users interact with). It allows developers to quickly create and efficiently serve static websites to users.

In a JAMstack web application, as much HTML as possible is pre-built and stored in a content delivery network (CDN). Instead of running a monolithic backend application on the server side to generate dynamic content, dynamic components of the application are based on APIs. Ideally, this results in a much faster user experience and a much simpler developer experience.

JAM stands for JavaScript, APIs, Markup.

  • JavaScript is the programming language used by web applications
  • An API (application programming interface) is a way to request data from someone else's program or application
  • Markup is code (HTML and CSS) that provides formatting instructions to browsers

Gatsby

Gatsby is a React-based open-source framework for creating websites and apps. It's great whether you're building a portfolio site or blog, or a high-traffic e-commerce store or company homepage. It’s more than a static site generator. As it is built on top of React, all the React goodness is at your fingertips, which enables you to take advantage of this powerful library to build interactive components right into your static website. Gatsby is also built with GraphQL, so you can query data and display it on your website any way you want.

Building a website with Gatsby/Netlify stack will help us with:

  • Search Engine Optimization (SEO)
  • Bounce Rates
  • Loading speed
  • Simplified and cheaper hosting
  • Better security
  • Developer and User Experience

Notable gatsby plugins used:

Plugin Description
gatsby-plugin-react-helmet React Helmet is a component which lets you control your document head using their React component.
gatsby-plugin-advanced-sitemap Generates a single or multiple sitemaps with full XSL templates
gatsby-plugin-robots-txt Create robots.txt for your Gatsby site.
gatsby-plugin-offline Adds drop-in support for making a Gatsby site work offline and more resistant to bad network connections.
gatsby-plugin-intl Support for multi lanugage websites
gatsby-transformer-sharp Processing images in a variety of ways including resizing, cropping, and creating responsive images.

Netlify

Netlify is an excellent option for deploying Gatsby sites. Netlify is a unified platform that automates your code to create performant, easily maintainable sites and web apps. They provide

  • continuous deployment (Git-triggered builds)
  • an intelligent, global CDN
  • full DNS (including custom domains)
  • automated HTTPS
  • asset acceleration and a lot more.

Their free tier includes unlimited personal and commercial projects, HTTPS, continuous deployment from public or private repos, and more.

And of course:


Setup

Setting up Contentful API

  • From space dashboard go to Settings > API keys
  • Click Add API key

Generated info is mapped to .env:

CONTENTFUL_SPACE_ID - "Space ID"
CONTENTFUL_ACCESS_TOKEN - "Content Delivery API - access token"
CONTENTFUL_PREVIEW_ACCESS_TOKEN - "Content Preview API - access token"

Access tokens can be found in "Content delivery / preview tokens" tab of "API keys" screen

Setting up Netlify site from Git repo

The process is pretty straightforward. On you team's dashboard go to Sites and click "New site from Git" and follow the wizard.

  1. Choose a Git provider (GitHub)
  2. select repository. Here make sure the Netlify has a correct Repo access which can be configured by clicking Configure the Netlify app on GitHub. below
  3. Select a branch to deploy (master) a) Build command will default to yarn build (which actually calls gatsby develop) which is fine. See common build configurations if you are setting up a different architecture. b) Leave default publish directory

Setting up Contentful Webhook for CD

Build hooks give us a unique URL to trigger a build. Contentful send a POST request to a webhook URL which will trigger a deploy from master branch. Once you've setup a static site that pulls in your content during the build process, you're ready to configure webhooks that will be triggered when you publish or unpublish content in your space.

Prerequisites

  • site must already be deployed to Netlify
  • must be configured for CD via a linked Git repo hosted with a Git provider

Netlify

Go to Site Settings > Build & Deploy > Build Hooks. Click Add build hook and name it something in lines of "Contentful hook" (optional). Copy the generated webhook url.

Contentful

Go to Settings > Webhooks and click Add Webhook. Give it a name and paste the URL from Netlify in the URL field. In the Triggers section, you can choose the events that will trigger the hook. For what the project needs, the events shown in the table below are enough.

Publish Unpublish
Entry ☑️ ☑️
Asset ☑️ ☑️

TBA

belgijski-ovcar-gatsby's People

Contributors

markoivanetic avatar gradskyops avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.