Welcome to my new page - a website-blog combo. Let's see how it's made.
Keng is really lazy; he wants to code as little as possible for this project.
We have two aims here:
- a website with sections for different topics
- a section dedicated for blogging
Let's get started. The source code is hosted on my repo.
We will host the site with Github Pages. Follow their instructions.
For the website we use Google Web Starter Kit (WSK). It is styled with Google MDL. You can also see it as a static-site generator. WSK houses a lot of optimization tools written by the Google team, and it uses familiar build tools such as
gulp for streamlined building.
For blogging we use Tinypress, which is really minimal - just write your post on the site in
Markdown, then hit
post. Tinypress will then push your material to your github pages.
But, it's not really that easy, is it? We wish to house the blog under a section of the website. The problem is - Tinypress or Jekyll needs to control and setup the root
index.html, i.e. it needs an empty repo to create a full site with its own resources. So, if you start with Tinypress, you can't really customize it much to be a website; instead you'll just get a bare blog.
So, Keng spent some time cracking Tinypress, and hacked it to merge under the Google WSK website.
Suppose you have set up your Github Pages together with the CNAME. Note that Github Pages needs an
index.html at the root; this is a must.
Next, clone the Google WSK elsewhere and copy the content (except its .git!) into your Github Pages repo. We need to hack its
gulp to tweak the default build.
Suppose you know how to run
gulp; otherwise it's really simple. Just install it, and run the commands from the terminal at project root.
This is how WSK organizes their folders and builds:
app/is where you do all the developments and tests. The
app/folder contains all website resources such as the
.jsfiles. Summon the dev build/preview by the command
dist/houses the files for deployment.
gulpwill source from
app/, minifies and optimizes files, and copy the built files to
gulp serve:mainruns the build then pulls up a deployment preview.
Now, recall that Github Pages requires the root folder to be the deployment build folder, since it needs
index.html at root. Keng has modified the
gulpfile so that the deployment build writes to the root. Use the same
gulp commands as before.
Now that the build system is set up, you can design the site. The original WSK provides a good starting boilerplate. Refer to Google MDL for usage. Or, you can look at the my
app/ folder. The page you're currently viewing has multiple tabs for different sections.
For Tinypress to be able to inject under the blog section, we add the template string snippet in
app/index.html, like so:
<div class="wrap"> <div class="container content "> <div class="posts"> ...<!-- template string here --> </div> </div> </div>
Put your custom
.css files under
app/styles/, and link them in
index.html under the
<!-- Your styles --> <!-- build:css styles/main.min.css --> <link rel="stylesheet" href="styles/yourstyle.css"> <!-- endbuild -->
Put your custom
.js files under
app/scripts/, and link them in
index.html under the
<!-- build:js scripts/main.min.js --> <script src="scripts/main.js"></script> <script src="scripts/github.js"></script> <!-- endbuild -->
gulp build system will pick up the resources, minify and optimize them, then relink the new resources for you.
Next, we wish to house the Tinypress a section, without changing how we post from it. Recall also, now that we have occupied the root folder, Tinypress cannot setup its resources normally. We need to hack.
Tinypress uses template strings. You will see the folders
_posts. Just so that Tinypress still gets access to the root
index.html, we add
The deployment build will finish building the resources, move the completed build
layout_preview.html for live preview, then copy
index.html for Tinypress to use.
With the template string we injected earlier into
app/index.html, now Tinypress gets a handle on the repo to inject the Markdown blog contents.
You're basically done. With the build system set up, and a small hack for Tinypress, you can update and customize the website however you like, and can write blog posts very easily from Tinypress. The best of both worlds!