Skip to content

Local Development

Guy King edited this page May 25, 2020 · 11 revisions

Linux / macOS

Setup

  • Install Docker and ensure the Docker daemon is running
  • Clone the repository git clone https://github.com/family-guy/homepage.git
  • From the project root, docker build --tag homepage-dev . --file Dockerfile.dev
  • With the image built, start a container
docker run --name homepage-dev --publish 4000:4000 --publish 35729:35729 \
--volume /path/to/homepage:/homepage --rm homepage-dev
  • Navigate to http://localhost:4000, you should see the site running
  • The site should update automatically after updates to source files (the first change might require a manual refresh in the browser)
  • To stop the Docker container, docker container stop homepage-dev

Create a new post

  • Find an image using Google Advanced Search, filtering on images with usage right "free to use or share"
  • Download the image to /path/to/image/
  • script/create-post.sh "<post-title>" /path/to/image
  • Navigate to post in browser

Add tag(s) to post

  • Add <tag_1> ... <tag_n> to front matter of the post
  • script/create-tag.sh <tag_1> ... <tag_n>

Viewing site on a mobile device

If your development machine and mobile device are connected to the same local network, e.g. to the same WiFi router, it is possible to view your changes on the mobile device:

  • Determine the private / local IP address of your development machine
    • ifconfig | grep "inet " | grep -v 127.0.0.1 to display the IP addresses of the devices on the network
    • One of the displayed IP addresses is the development machine's
    • On the mobile device, try each IP address at port 4000 until you see the site

Troubleshooting

If when running jekyll serve you get gem not found error, e.g.

Could not find <gem-name> in any of the sources (Bundler::GemNotFound)

Can check the gem is missing with gem query --local. If it is missing,

  • sudo gem install <gem-name> (without version number)
  • Add <gem-name> to Gemfile
  • bundle install
  • jekyll serve
  • If above does not work, try bundle exec jekyll serve
Clone this wiki locally