Intro to Jekyll Themes and Layout Creation in GitHub Pages |Video upload date:  · Duration: PT7M40S  · Language: EN

Learn how to create Jekyll themes and custom layouts for GitHub Pages with practical steps for templates assets and deployment.

If you want a tidy static site that does not look like it was stitched together by a panicked hedgehog then build a proper Jekyll theme. This guide walks through creating layouts, using Liquid templates, organizing assets and preparing your theme for GitHub Pages deployment. Technical bits stay accurate and useful. The snark is optional but recommended.

Plan your theme folder layout

Start with a predictable folder structure. The usual suspects are:

  • _layouts for top level templates like default or post
  • _includes for reusable fragments such as header, nav and footer
  • assets for CSS, JS and images so the theme stays portable

Keeping templates small and reusable prevents copy paste chaos and makes maintenance bearable.

Create layouts and include reusable chunks

Place HTML templates in the _layouts folder. A common file is default.html which wraps page content with document head and footer markup. Use Liquid tags to inject page content and site data using expressions like

Overview

You need Java 7 and the JAVA_HOME variable set for some stubborn legacy build or a tool that refuses to move on. This guide gets you the JDK, shows how to install it on Windows and Linux, walks through setting JAVA_HOME and verifies the setup from the command line. Yes this still matters in the year of newer Java versions.

Get the Java 7 JDK

Download the JDK from the Oracle archive or use a trusted package repository. If a modern Java is acceptable pick that instead to save yourself future pain. On Linux the system package manager is the easiest option when available.

Install the JDK

Windows

Run the installer and follow the wizard like a functioning human. If you prefer scripts you can install the MSI or unpack an archive and then set environment variables with the command shown later. A common installation path looks like

C\Program Files\Java\jdk1.7.0_xx

Linux

Use your distro package manager or extract a tarball into a predictable location. Example for Debian style systems

sudo apt-get install openjdk-7-jdk

If you manually unpacked a tarball move the JDK folder to a stable path such as /usr/lib/jvm so tools can rely on it.

Set JAVA_HOME

Windows

Open System Properties and Advanced Environment Variables and add a new system variable named JAVA_HOME with the path to your JDK. For scripted installs use the setx command shown here

setx JAVA_HOME "C\Program Files\Java\jdk1.7.0_xx"

Important note that the new value only appears in new shells. Close and reopen any command prompt windows or restart your IDE to make it notice the change.

Linux

Edit your shell profile such as ~/.bashrc or a system profile script and add an export line. Example

export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64

Save and reload the profile with a new shell or with source ~/.bashrc if you must avoid a reboot. Yes you will still have to reopen terminals.

Verify the installation

Confirm the JDK is usable and that the environment variable points at the right place. Run these commands in the appropriate shell

java -version
# on Linux
echo $JAVA_HOME
# on Windows in cmd
echo %JAVA_HOME%

If java -version prints a Java 7 runtime and the echo output shows the JDK path you are golden. If not double check the path and remember Windows paths differ from Linux paths. Mixing them is a fast path to confusion.

Troubleshooting and tips

  • If a build still uses the wrong Java check for tool specific settings or bundled runtimes that override JAVA_HOME.
  • In CI set JAVA_HOME in the runner configuration or use container images that already include the right JDK.
  • If you can, plan a migration off Java 7 to a supported release to avoid security and compatibility grief later.

This guide covered obtaining the JDK installing it on Windows and Linux setting JAVA_HOME and verifying the setup. Follow the platform specific steps and keep your paths sensible unless you enjoy debugging path related drama.

and Your awesome title. That makes your theme flexible and lets you change a header in one place instead of a hundred places.

Use _includes for repeated bits

Navigation, social links and footers belong in _includes. Then call them from layouts with include statements so you avoid duplicating HTML. Smaller templates mean faster debugging and fewer late night regrets.

Organize assets for portability

Keep CSS and JavaScript in an assets folder and reference files with relative paths. That helps the theme work when moved between repos or used as a gem based theme. Avoid absolute paths that will break when the site is deployed under a baseurl.

Configure the site with front matter and _config.yml

Every page or post needs a front matter block to select a layout and set page specific variables. The front matter is that small YAML block at the top of a file. Edit _config.yml to set global options such as baseurl and other flags that control behavior. Test different settings locally before committing to avoid surprises on the live site.

Preview locally and deploy to GitHub Pages

Run the site locally with the jekyll serve command to preview changes. Local testing saves the embarrassment of broken pages on the public site. When you are happy push changes to the branch configured for GitHub Pages. GitHub Pages will build the site and your theme will appear if the repo and branch settings match what GitHub Pages expects.

Quick checklist for a maintainable theme

  • Use _layouts and _includes from the start
  • Keep markup small and prefer includes over copy paste
  • Store assets in a dedicated folder and use relative links
  • Use Liquid to pull in site variables and page content
  • Test locally with jekyll serve before pushing

Follow those steps and you get a reusable Jekyll theme that plays nicely with GitHub Pages. You will also avoid the kind of layout rot that haunts abandoned projects. Now go make something that does not embarrass your future self.

I know how you can get Azure Certified, Google Cloud Certified and AWS Certified. It's a cool certification exam simulator site called certificationexams.pro. Check it out, and tell them Cameron sent ya!

This is a dedicated watch page for a single video.