Are you familiar with basic HTML tags? or, Markdown syntax? Can you understand extremely basic CSS entries? Are you comfortable with the GitHub web interface?
Yes?
Then come, build your own website on GitHub by using Jekyll to generate a website for you from the Liquid templating engine.
No, you don't need to know either Jekyll or Liquid to get started. Once you've taken off with this starter pack, though, you'll learn as much as you need to along the way; nothing more, nothing less.
Why can't you just use plain HTML (or plain Markdown), CSS, JS to build your website through
gh-pages
on GitHub? You absolutely can!But when you use
Liquid
, you can use variables that'll output their values on the page at buildtime, and you can use templates for repeated blocks of text. As an example, suppose you have a help portal where certain parts of text must change according to certain parameters, you could useLiquid
to build your pages throughJekyll
and then render them on GitHub (or any other host).
This template is meant for beginners. You need have a basic knowledge of HTML, CSS, and JS.
Because GitHub uses Jekyll to render pages, it's essential to use a directory structure that Jekyll understands. This template contains the barest minimum files that you need to get a website up and running.
- _layouts # folder to contain HTML templates -- default.html # file that governs the layout of pages - css # folder to contain stylesheets -- main.css # file that governs the look and feel of pages - topics # folder to contain pages of the website -- page1.html # a page of the website -- page2.md # another page of the website -- page3.md # still another page of the website - _config.yml # basic configuration info - index.html # landing page of the website
- Scroll up, locate the Use this template button, and click it.
- Specify a repository name. The name you choose will be used in the URL of your website, like this:
https://_yourGithubID_.github.io/_repositoryName_
. - Click Create repository from template. The files and folders from this repository are copied over to a new repository for you.
- In the new repository you just created, locate the Settings button and click it. Scroll down to the section called GitHub pages and, in the list for Source, ensure that master branch is selected.
- In the
_config.yml
file, put down your own name and replace the value ofbaseurl
with the name of your repository. This name is the same as the one you specified in step 2 earlier. - Navigate to
https://_yourGithubID_.github.io/_repositoryName_
. What you see on the webpages is pretty much the same as what you saw at https://aninditabasu.github.io/jekyll-github-starter-pack. You now have a starting point to work with. - Return to the Code page on the GitHub web interface, and edit the files so that they fit your vision for your website:
- In the
topics
folder, edit the.html
and.md
files as you deem fit. Just use HTML or Markdown tags like you normally would, but retain the text of lines 1 through 4 as is. Do not touch them 🙂 Feel free to change anything from line 5 onwards. - In the root folder, edit the
index.html
file, which is the landing page of your website, as you deem fit. Again, do not touch lines 1 through 4.
- In the
- (Optional) Delete the
LICENSE
andREADME.md
files. They're nice to have for a GitHub repo but you don't really need them to get your website up and running. - Go to
https://_yourGithubID_.github.io/_repositoryName_
. You should now see your own content on the website.
-
Open a file in the
topics
folder and play with lines 1 to 4 🙂 This part is calledFront Matter
in Jekyll-Liquid parlance. Thetopics
>.html
ortopics
>.md
files in this template have only two entries for front matter:layout
, the value of which in this case isdefault
. This tells the build engine to use a file calleddefault
from the_layouts
folder to render the page.title
, the value of which in this case ispage1
. This is the text that is displayed as the title on browser tabs.
This front matter is actually a
YAML
code block and, for your files to render correcly, should always be placed at the very top of the file. You can specify your own variables here, and call the value of those variables on the page later. For example, you can define a variable like this:hit_list: ['Cruella', 'Villanius', 'Voldemort']
and then pick each item from this list and use it somewhere on the page. -
Edit the
_layouts
>default.html
file to play around with the look and feel of your website. If you've renamed any of the files in thetopics
folder, remember to use those names in the<nav>
section of the file.
Remember, however, that your files in the
topics
folder as rendered as.html
on your website. Therefore, even if you have a file namedpage2.md
, if you're calling it (referencing it) in thedefault.html
file, call it aspage2.html
.
Use the css
folder to place your styling information. If needed, create image
and js
folder at the root level (the same level as css
and topics
) for your pictures and JavaScript files. You could, of course, have all JavaScript, images, and stylesheets right at the root level itself (instead of keeping them inside special folders), but having separate folders for them looks a bit less cluttered.
- Rename the
topics
andcss
folders (andimages
andjs
if you have them), and use any names for any files that you place inside these folders. Just, don't rename_layouts
because that name is needed by the build engine. Also, do not rename either_config.yml
orindex.html
.
As you become comfortable with these files, you can explore the Jekyll documentation for more info about what more files and folders you can put into use for your website. Here are some resources:
- Liquid introduction
- Jekyll variables and includes