Skip to content

Netlify-based website for Code for Tucson created in July 2022.

Notifications You must be signed in to change notification settings

CodeForTucson/new-cft-website

 
 

Repository files navigation

Draft and prototyping CMS for Code for Tucson

Description and usage

Using NetlifyCMS to build a mostly static site, with easy to access content for later updating.

Why are there so many things on such a simple website

This page uses 11ty, which is a Jamstack and Nunjucks as a templating engine.

What this means is you can build reuseable components and pages using Nunjucks syntax, then run 11ty to build the static website to be hosted. It looks complicated, but this method allows for faster page building, as a signle component can be used across multiple pages quickly.

Quickstart

  • Download Node.js and install it to your computer
  • Clone this repo - Either download it and unzip it somewhere or clone it with git
  • In a powershell or terminal navigate to the root directory of the project (Where the package.json is)
  • Run npm install
  • Run npm run serve
  • Start coding

These steps should get you a local server running at https://localhost:8080/ that will refresh automatically whenever a file is changed and then saved in the project directory. You get to see your changes made in real time.

hint: If you aren't seeing your changes then you might have a syntax error. ctrl+c in the terminal to kill the servers, then run npm run serve again to get them started up. If there's an error you'll see it in the terminal.

netlifyCMS

If you followed the quickstart steps above, the command also started a local backend server for netlifycms. If you go to https://localhost:8080/admin you should be met with a login screen. From here you can check out the CMS. It's a bit more limited than originally expected, but it is customizeable so has a lot of potential.

NetlifyCMS and Netlify are not actually associated with each other, but hosting a netlifycms site on netlify is incredibly easy. Unfortunately, at this time a code for tucson netlify account does not exist, so this static page is being hosted on github pages. This means authentication for the CMS is broken, but the page is still hosted.

If you notice you're missing some images, see the Hosting the static page in a subdirectory section. The short version is that using npm run serve-subdir might fix your problem

package.json
  "scripts": {
    "build": "npx eleventy",
    "watch": "npx eleventy --watch",
    "serve": "concurrently --kill-others \"npx netlify-cms-proxy-server\" \"npx eleventy --serve\"",
    "debug": "DEBUG=* npx eleventy",
    "build-subdir": "npx eleventy --pathprefix=new-cft-website --output=new-cft-website/docs",
    "serve-subdir": "npx eleventy --serve --output=new-cft-website/docs --pathprefix=new-cft-website"
  },

Hosting the static page in a subdirectory - and how it doesn't play nice with the CMS.

The CMS stores media based on the configuration at /admin/config.yml

media_folder: "/new-cft-website/static/img"

The CMS keeps all posts and pagers in markdown files across the directory. The media location in the .md file will be whatever was set as the media_folder value when the CMS was used.

All this means is that if you're using the fancy CMS screens to make updates, it's going to use the value in that file so if the website is hosted in subdirectory, like on a github page without a custom domain, then you will need to find and replace the media path in each of the .md file. Other files don't have this problem because the --pathprefix option on the eleventy command takes care of it.

None of this is of concern if the page is hosted on netlify.

Todo

  • Reset styles
  • Cleanup directories
  • Homepage
  • Projects
  • Get involved
  • Update project posts
  • About page
  • Code of conduct
  • Update this Todo

Contributing

If you're new to coding, we recommend installing:

  • a text editor like VS Code
  • Git which is a version control system. This helps people collaborate on projects. If you're new to git, take a look a Github Git tutorial

Feel free to dive in! Open an issue, submit Pull Requests (PRs), or even start your own project!

If you'd like to get your feet wet, take a look at some good first issues.

Brief Tutorial

We recommend newcomers to first read an old guide. However, the developer community recently agreed to rename the master branch to main. As a refresher, to contribute, take the following steps:

  • First, clone the repo
git clone <repo_url>

If you are not added yet as a collaborator, you may first need to fork the repo in order to contribute.

  • Create a new branch from the main branch (or master, or whatever branch you want to work off of).
git checkout -b <your_new_branch_name>
  • Make some code edits in your code editor. Then stage your changes with:
git add <the_file_you_modified>
  • Then you need to commit your changes with a message
git commit -m 'A brief summary of your code'
  • Push your changes to the remote repo (hosted here on Github):
git push -u origin <your_new_branch_name>
  • Finally, on Github, create a Pull Request if you don't have write access to the repository.

Standard Readme follows the Contributor Covenant Code of Conduct.

Learning Resources

Websites

Video Resources

Feel free to add resources you'd find helpful, or request new ones be added by creating an issue!

Social

Visit us on Slack Join us on Meetup

Eleventy Netlify Boilerplate

Click the button below to try it out!

Deploy to Netlify

About

Netlify-based website for Code for Tucson created in July 2022.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Nunjucks 51.8%
  • CSS 38.5%
  • JavaScript 8.9%
  • HTML 0.8%