Learn to customize your own blog with confidence

Code it Pretty is an archive of tutorials from 2012-2015. Tutorial details may be outdated. More Info

Showing posts with label typepad. Show all posts
Showing posts with label typepad. Show all posts

Add an Icon to Blog Post Titles with CSS

post title icons with CSS

A little icon next to your post title is a cute way to bring the design elements of your theme into your blog posts. And, it's easy to do with a bit of CSS! You'll probably spend more time choosing the perfect icon than you will on adding the CSS to your blog.

Demo

blog post title icon tutorial demo

For a live demo, visit codeitpretty.blogspot.com, where I've added a heart icon to each of the post titles.

Who Can Use This Tutorial

If you can add CSS to your blog, you can do this! Blogger, self-hosted Wordpress, and Typepad Unlimited users, you're all set. Wordpress.com users will need the Custom CSS upgrade.

Before You Get Started

You'll need two things to use this tutorial: an icon, and the class name of your post titles. The icon is up to you, but I'll show you how to find your post title class name.

Blogger & Typepad users who use a standard template and haven't made changes to the post title class, your post title classes are:

Blogger: post-title

Typepad: entry-header

Wordpress title classes vary by theme. If you're on Wordpress, or you've made changes to your Blogger or Typepad template classes, here are two ways to find your post title class.

  1. Use your browser's developer tools. If you're using Firefox or Chrome, you can use your browser's developer tools to identify your post title class by right-clicking a post title and selecting "Inspect Element" from the menu.
  2. Check your blog's source code. Using your browser's "View Source" option, open up your blog's source code. Find a post title within your source, and find its class. The class might be inside your post title's link element, or nearby in the code. It's usually something like post-title, entry-title, headline, etc.

Once you have your icon and you've found your post title's class, you're ready to add your title icon!

Step One: Upload Your Icon

Blogger users, upload the icon to your blog's Picasa Web Album. Wordpress users, upload the image to your media library. Typepad users, upload the image to the File Manager. You can also use Photobucket or another image hosting service if you prefer. Wherever you upload it, copy the direct link to the image. You'll need that soon.

Step Two: Add the CSS

You only need to add this CSS to your template once and the icons will appear on every post title.

In Blogger, go to Template > Customize > Advanced > Add CSS. If you're on Typepad, go to Design > Custom CSS. On Wordpress your custom CSS location will vary. If you're using Jetpack's Custom CSS option, it's under Appearance > Edit CSS.

I'm going to demonstrate this with the class .post-title, since I'm on Blogger. Remember to change it if you blog elsewhere! Here's the basic CSS:

  .post-title {
    background: url(ICON-IMAGE-URL-HERE) no-repeat left transparent;
    padding-left: 15px;
    }

Now that you've seen the CSS, let me break it down for you!

  • In the first line, the selector (.post-title in the example) tells the CSS to style all the links with the class post-title. Again, change that if .post-title isn't your class. Don't forget the dot (.) in front of the class name!
  • The next line has four parts:

    1. background: url(ICON-IMAGE-URL-HERE) sets a background image for the selected titles. Replace the text inside the parentheses with the direct link to your icon image.
    2. The "no-repeat" value makes it so the image only appears once for each link.
    3. "Left" places it to the left of the URL.
    4. "Transparent" sets the background color of the link and its associated icon.
  • The last line, padding-left: 15px; , creates a bit of room between the icon and the beginning of your post title. You may need to adjust the padding size, 15px is just a starting point.

Variations

Now that you've got the idea, you might want to try one of these variations. Thanks to Joelle and Marina for their prompts in the comments!

These variations work in modern browsers, but aren't compatible with older versions of Internet Explorer. They don't cause any problems in older IE, they just don't show up.

Icon Above Your Title

If you'd like to place your icon above your title, find the class of the div surrounding your post using the class-finding methods described above. Once you've found the class, use this basic CSS:

.post-outer:before {
content: url(YOUR IMAGE URL HERE);
}

I used ".post-outer" because I'm on Blogger. If you're on another platform, you may need to use a different class.

You can also center the icon above your post title if you prefer.

If you'd like to center the icon, the CSS is:

.post-outer:before {
content: url(YOUR IMAGE URL HERE);
display: block;
width: ICON WIDTH IN PX HERE;
margin: 0 auto;
}
Two Icons

If you'd like to add two icons to either side of your title, you can use :before and :after content to place the image. If you use this method, the second icon will be placed at the end of your title's text, like in these examples:

icon before and after a short blog post title
icons before and after an unusually long blog post title

Here's the basic CSS:

.post-title:before,
.post-title:after {
content: url(YOUR IMAGE URL HERE);
}

Remember that I used .post-title because I'm on Blogger. If you're on a different platform, be sure to change the selector if needed.

Back Up Your Blog

back up your blog

Part One of the "Get Your Blog Ready for Next Year" series.

I know it's not exciting or glamorous, but backing up your blog is essential to your blog's health. Think of it as good blogging hygiene! Now that we're coming up on a new year, it's a great time to back up your blog files and plan to make it a regular habit.

Why You Should Back Up Your Blog

One simple reason: if you have a backup of your blog, it's much easier to get back to blogging business in case of a calamity. Blogs can get hacked, templates can get mangled... stuff happens. And a backup takes a lot of the pain out of the recovery process when it does.

You may never experience one of those blog-disrupting events. I hope you don't, they're no fun. But, it's better to have something you don't need than need something you don't have. And, it's so easy to back up, you really have no excuse not to!

Where to Store Your Backup Files

Let's talk about where you're going to put those backup files before we talk about how to get them. If you have your storage plan in place before you download the files, you're more likely to stick to it.

Naturally, you should keep a copy of your backup files handy on your computer. But, you should also keep another copy somewhere safe. A spare will save your blog if your backup files are corrupted or accidentally deleted (or if your computer meets an untimely end).

Here are three places you can stash your backup files "in the cloud", so you can be sure that your files will live on — even if you upend an entire latte onto your laptop.

  • Dropbox: Dropbox is my favorite cloud service. I find the interface intuitive and I love the desktop & mobile apps. Dropbox starts you out with 2GB of free space.
  • Google Drive: Formerly known as Google Docs. If you've got a Google account, you already have a Drive account with 5GB of free storage space.
  • Amazon Cloud Drive: If you're an Amazon addict like me, you already have an Amazon Cloud Drive account with 5GB of free storage space. If you need extra space, a paid Cloud Drive account costs less than Dropbox or Google Drive's expanded storage options.

How To Back Up Your Blog (By Platform)

Now that you know where you're going to put your backup files, you're ready to get started with your back up! Here's how to do it on the major blogging platforms.

Blogger

There are three easy steps to completely back up your Blogger blog.

  1. First, download your template by going to "Template" and clicking the "Backup/Restore" button in the upper right. Save the resulting file.
  2. Next, go to "Settings" > "Other", and select "Export Blog" under the "Blog Tools" menu. Save the export file. It includes all of your blog posts and comments.
  3. Finally, back up the Picasa album containing your blog's photos. Links to them are included in the .xml export file you downloaded in step 2, but this guarantees that you'll have your photos no matter what.

Self-Hosted Wordpress

The official instructions for backing up self-hosted Wordpress are in the Wordpress codex. But, as with all things Wordpress, there's a plugin for that! Lisa from Elembee has a quick tutorial on using a plugin for your backup in her post Blogkeeping: Backing Up Your Blog.

Wordpress.com

If you have a Wordpress.com blog, you can use the Export feature to save a copy of your content. You don't need to save a copy of your template if you use Wordpress.com.

Typepad

Typepad backups are not quite as streamlined as other blogging services. You can back up your posts using the built-in Export feature. If you have a Typepad Basic template, you don't need to back up the template; Typepad Advanced users should copy and paste their templates into .txt files — there's no direct download option.

Now, here's where it gets weird: there's no easy way to back up your photos. Typepad actually suggests visiting each page of your blog and copying the photos as a means of backing up (pardon me while I LOL to death). If you blog on Typepad and have a folder of photos from your blog on your computer, save a copy of that to a cloud service so you've got them safe, but keep in mind it could be time-consuming to restore them to your blog.

Tumblr

Unfortunately, Tumblr blogs are the hardest to back up. There is an official Tumblr backup tool, but it's a desktop application that only works on Mac. Also, it doesn't save submitted posts or any of your posts' notes. There is a web-based, third-party tool called Tumblelog Backup Tool, but it's not officially supported by Tumblr.

You're All Backed Up!

Not so hard, right? Now that you've done it, schedule your next backup session. I back up everything every three months, and back up my template separately anytime I make a template change. A similar schedule will suit most other bloggers fine, too.

What's Next?

Move on to part two of the "Get Your Blog Ready for Next Year" series: Improve Your Navigation.

Acorn photo CC-BY Edd Prince