Building a WordPress Bootstrap Theme
There are many tutorials about building Bootstrap Themes for WP. Here’s another one – my own personal journey. I started by using this tute: http://blog.teamtreehouse.com/responsive-wordpress-bootstrap-theme-tutorial
LET’S GIT BUSY
First I created a new repo on github. It’s here:
https://github.com/jamorat/amoratis-wordpress-theme
Then I cloned it to my local computer. I then added a git submodule to contain bootstrap. Here’s the tute I used for accomplishing that:
http://git-scm.com/book/en/Git-Tools-Submodules
Why did I use a git submodule? Because bootstrap is on github as its own project. I don’t want to be committing a specific version of bootstrap in my own repo. I don’t really want it to be ‘baked in.’ I’d rather be able to pull the latest changes from up stream.
So my local computer now had the following folder structure:
amoratis-wordpress-theme
–bootstrap
I then created an index.php file with the following text:
<!DOCTYPE html>
<html lang=”en”>
<head>
<meta charset=”utf-8″>
<title>Bootstrap, from Twitter</title>
<meta name=”viewport” content=”width=device-width, initial-scale=1.0″>
<meta name=”description” content=””>
<meta name=”author” content=””>
<!– Le styles –>
<link href=”../assets/css/bootstrap.css” rel=”stylesheet”>
<style type=”text/css”>
body {
padding-top: 60px;
padding-bottom: 40px;
}
</style>
<link href=”../assets/css/bootstrap-responsive.css” rel=”stylesheet”>
<!– Le HTML5 shim, for IE6-8 support of HTML5 elements –>
<!–[if lt IE 9]>
<script src=”http://html5shim.googlecode.com/svn/trunk/html5.js”></script>
<![endif]–>
<!– Le fav and touch icons –>
<link rel=”shortcut icon” href=”../assets/ico/favicon.ico”>
<link rel=”apple-touch-icon-precomposed” sizes=”144×144″ href=”../assets/ico/apple-touch-icon-144-precomposed.png”>
<link rel=”apple-touch-icon-precomposed” sizes=”114×114″ href=”../assets/ico/apple-touch-icon-114-precomposed.png”>
<link rel=”apple-touch-icon-precomposed” sizes=”72×72″ href=”../assets/ico/apple-touch-icon-72-precomposed.png”>
<link rel=”apple-touch-icon-precomposed” href=”../assets/ico/apple-touch-icon-57-precomposed.png”>
</head>
<body>
<div class=”navbar navbar-inverse navbar-fixed-top”>
<div class=”navbar-inner”>
<div class=”container”>
<a class=”btn btn-navbar” data-toggle=”collapse” data-target=”.nav-collapse”>
<span class=”icon-bar”></span>
<span class=”icon-bar”></span>
<span class=”icon-bar”></span>
</a>
<a class=”brand” href=”#”>Project name</a>
<div class=”nav-collapse collapse”>
<ul class=”nav”>
<li class=”active”><a href=”#”>Home</a></li>
<li><a href=”#about”>About</a></li>
<li><a href=”#contact”>Contact</a></li>
<li class=”dropdown”>
<a href=”#” class=”dropdown-toggle” data-toggle=”dropdown”>Dropdown <b class=”caret”></b></a>
<ul class=”dropdown-menu”>
<li><a href=”#”>Action</a></li>
<li><a href=”#”>Another action</a></li>
<li><a href=”#”>Something else here</a></li>
<li class=”divider”></li>
<li class=”nav-header”>Nav header</li>
<li><a href=”#”>Separated link</a></li>
<li><a href=”#”>One more separated link</a></li>
</ul>
</li>
</ul>
<form class=”navbar-form pull-right”>
<input class=”span2″ type=”text” placeholder=”Email”>
<input class=”span2″ type=”password” placeholder=”Password”>
<button type=”submit” class=”btn”>Sign in</button>
</form>
</div><!–/.nav-collapse –>
</div>
</div>
</div>
<div class=”container”>
<!– Main hero unit for a primary marketing message or call to action –>
<div class=”hero-unit”>
<h1>Hello, world!</h1>
<p>This is a template for a simple marketing or informational website. It includes a large callout called the hero unit and three supporting pieces of content. Use it as a starting point to create something more unique.</p>
<p><a class=”btn btn-primary btn-large”>Learn more »</a></p>
</div>
<!– Example row of columns –>
<div class=”row”>
<div class=”span4″>
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
<p><a class=”btn” href=”#”>View details »</a></p>
</div>
<div class=”span4″>
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
<p><a class=”btn” href=”#”>View details »</a></p>
</div>
<div class=”span4″>
<h2>Heading</h2>
<p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
<p><a class=”btn” href=”#”>View details »</a></p>
</div>
</div>
<hr>
<footer>
<p>© Company 2012</p>
</footer>
</div> <!– /container –>
<!– Le javascript
================================================== –>
<!– Placed at the end of the document so the pages load faster –>
<script src=”../assets/js/jquery.js”></script>
<script src=”../assets/js/bootstrap-transition.js”></script>
<script src=”../assets/js/bootstrap-alert.js”></script>
<script src=”../assets/js/bootstrap-modal.js”></script>
<script src=”../assets/js/bootstrap-dropdown.js”></script>
<script src=”../assets/js/bootstrap-scrollspy.js”></script>
<script src=”../assets/js/bootstrap-tab.js”></script>
<script src=”../assets/js/bootstrap-tooltip.js”></script>
<script src=”../assets/js/bootstrap-popover.js”></script>
<script src=”../assets/js/bootstrap-button.js”></script>
<script src=”../assets/js/bootstrap-collapse.js”></script>
<script src=”../assets/js/bootstrap-carousel.js”></script>
<script src=”../assets/js/bootstrap-typeahead.js”></script>
</body>
</html>
And a css file with the following text content:
/*
Theme Name: WP Bootstrap
Theme URI: http://teamtreehouse.com/wordpress-bootstrap-theme-tutorial
Description: A demo theme built to accompany the Treehouse blog post <a href=”http://teamtreehouse.com/wordpress-bootstrap-theme-tutorial”>How to Build a WordPress Theme with Bootstrap</a>.
Author: Zac Gordon
Author URI: http://teamtreehouse.com/
Version: 1.0
Tags: responsive, white, bootstrap
License: Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
License URI: http://creativecommons.org/licenses/by-sa/3.0/
This simple theme was built using the example Bootstrap theme “Basic marketing site” found on the Bootstrap web site http://twitter.github.com/bootstrap/examples/hero.html
*/
and lastly a file called screenshot.png