Giter VIP home page Giter VIP logo

example-company-website-gatsby-sanity-combo's Introduction

A sample company website built with Gatsby & Sanity.io

This examples combines Gatsby site generation with Sanity content management in a neat little company website. Read the blog post and see the getting started video.

Watch a video about the company website built with Gatsby using Sanity.io as a headless CMS

See the example up and running

Features

A company website built with Gatsby

  • ๐Ÿ“ก Real-time content preview in development
  • โฑ Fast & frugal builds
  • ๐Ÿ—ƒ No accidental missing fields/types
  • ๐Ÿงฐ Full Render Control with Portable Text
  • ๐Ÿ“ธ gatsby-image support
  • ๐Ÿ”ง Minimal configuration

Sanity Studio with a schema for

  • ๐Ÿข Company info
  • ๐Ÿ“ƒ Pages
  • ๐Ÿ‘จ๐Ÿผโ€๐ŸŽจ Projects
  • ๐Ÿ‘ฉ๐Ÿพโ€๐Ÿ’ป People
  • ๐Ÿ“ฐ Blog posts

Installation

Read the step-by-step blog post.

git clone [email protected]:sanity-io/example-company-website-gatsby-sanity-combo.git
cd example-company-website-gatsby-sanity-combo
npm install

# Install or upgrade the Sanity CLI to
# make sure you are on v0.140.0 or higher
npm install -g @sanity/cli
# Set up Sanity.io account and project (โ‰ˆ 45s)
npm run init

See the getting started video for a walkthrough of the installation.

Enable Gatsby watch mode for drafts

We have enabled the watch mode in the gatsby-source-sanity plugin, which means that your frontend will automatically update with content changes whenever you publish them. If you want the frontend to show content changes in real time, you must do the following:

  • Go to manage.sanity.io and find your project (or run the command sanity manage in the studio folder)
  • Navigate to Settings->API and scroll down to the Tokens section
  • Add a new token and give it read privileges.
  • Copy the .env-example file to a file called .env in the /web folder
  • Add your new token to the key: SANITY_TOKEN="<token here>"

If you restart the local development server, it will now show unpublished changes from the Studio. Note that the .env file is ignored by Git, because the token gives access to unpublished content in the API.

Usage example

This project demos Sanity.io with Gatsby using our source plugin. It's a good starter for a simple company site, a portfolio site for an agency or a personal blog with an attached portfolio.

We tried to strike a balance between a useful example and a minimal footprint to make it easier to iterate on design and content model. Let us know should you have questions!

Development setup

Run it

npm start
# Studio at http://localhost:3333
# Web frontend at http://localhost:8000
# GraphiQL explorer at http://localhost:8000/___graphql

Development workflow

We wrote a blog post about how to use this example, but if you would like to just start tinkering:

  • The Sanity Studio keeps its schemas in ./studio/schemas. We will hot reload the editor when you edit them so just start experimenting. Read more about our schemas here.
  • We followed Gatsby conventions and you can read all about them here.
  • If you want Gatsby to not throw errors on missing fields for unpopulated data you need to redeploy the GraphQL API so we can generate schemas โ€“ย npm run graphql-deploy

Deployment

# Deploy a GraphQL API and schema to Sanity
npm run graphql-deploy

# Deploy the Sanity Studio to *.sanity.studio
npm run sanity-deploy

# Build & deploy to Zeit's Now. Remember to set `basePath` to "/studio" in sanity.json
npm run now-deploy

Deploy on Netlify: If you want to deploy the Gatsby site to Netlify we added a netlify.toml config for you.

Fork or clone the example to your GitHub account. After adding your repo to Netlify youโ€™ll get automatic builds & deploys when pushing to master. You can also add a webhook to get deploys on content changes.

Deploy on Cloudflare: If you want to deploy the Gatsby site to Cloudflare we added a wrangler.toml and workers-site/ to both studio and web.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request

License

MIT

example-company-website-gatsby-sanity-combo's People

Contributors

chrislangston avatar dashon-hawkins avatar dependabot-preview[bot] avatar dependabot-support avatar evenwestvang avatar exvuma avatar jorngeorg avatar kmelve avatar magneh avatar mariuslundgard avatar nilsborg avatar rexxars avatar rogeliorv avatar runeb avatar

Stargazers

 avatar

Forkers

sretja

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.