Build a Simple Tumblr Theme with Bootstrap

If you’ve ever looked at all the wonderful Tumblr themes and wondered what it takes to build a Tumblr theme from scratch, then this tutorial is for you. In this post, I’m going to show you how to use Bootstrap and Tumblr’s special operators to create a theme you can use for your Tumblr blog.

Here’s what you need to get started:

  • a Tumblr account
  • a basic understanding of Bootstrap, the popular front-end framework.

Our Basic HTML and Bootstrap Resources

A Tumblr theme is just an HTML file that uses Tumblr’s special operators. We’ll start off by creating a new file using our favorite text editor and adding the following boilerplate HTML code to it:

[code language=”html”]


Next, we’ll add the necessary Bootstrap resources. Bootstrap CDN makes it easy to add the files to your Tumblr theme. Just put the following in your theme’s head:

[code language=”html”]

Also add the following before the closing body tag:

[code language=”html”]


Adding Custom Styles

This Tumblr theme is going to have a narrow layout that will be 550px wide. It’s also going to have a 50px-tall, fixed-position header. Add the following to the theme’s head to handle these requirements:

[code language=”css”]


Creating the Tumblr Theme Header

We’ll use Bootstrap’s navbar to create a header for our Tumblr theme. This allows us to use our first Tumblr variable: {Title}. The {Title} variable refers to the title of the blog. The following code is added to the body of the theme:

[code language=”html”]


It’s a good idea to use the {Title} variable in the HTML </code> tag as well:</p> <p>[code language=”html”]<br /> <title>{Title}

If you were to apply the theme to your Tumblr blog now, it would look like this, with just white space below it:

Creating a Container to Hold Posts

Next we’ll add a div that we can use as a container for all Tumblr posts. Add the following code below the nav element:

[code language=”html”]


As you might already know, Tumblr lets you add different types of posts to your blog. For the sake of simplicity, we’re going to handle the following post types:

  • text
  • photo
  • quote

{block:Posts} is a Tumblr block that gives us a list of all the posts available on a blog.

Add the following code inside the posts container:

[code language=”html”]

Next, to determine the type of the current post, we’re going to use the following blocks:

  • {block:Text}
  • {block:Photo}
  • {block:Quote}

For any post, only one of these will be rendered.

Handling Text Posts

Text posts usually have a title and a body that can be accessed using the variables {Title} and {Body}, respectively. Add the following code inside the {block:Posts} tag.

[code language=”html”]




Handling Photo Posts

Photo posts have a caption and a photo. The caption can be accessed using the {Caption} variable. Accessing the photo is a little more complicated. To make it easier for you to use consistent image sizes all over your blog, Tumblr provides you with scaled versions of photos.

For example, to make sure your photo isn’t wider than 500px, you could use the variable {PhotoURL-500}. Similarly, if you want to make sure the photo isn’t wider than 100px, you could use the variable {PhotoURL-100}.

For this Tumblr theme, I’m going to use {PhotoURL-500}.

We can use a Bootstrap card to show the photo and its caption.

The code to handle photo posts would then look like this:

[code language=”html”]

Card image cap



Continue reading %Build a Simple Tumblr Theme with Bootstrap%

Powered by WPeMatico