From TextMate to WordPress

(Editors note: The following post is a guest post written by Joseph McLaughlin, a junior attending Brigham Young University – Idaho. Joseph is a 17 year old (turning 18 next month), code monkey and geek. Subscribe to his blog and follow him on Twitter.)

Have you ever wished that you could write new blog posts for your WordPress blog without having to log in and mess with the WYSIWYG (What You See Is What You Get) editor? Well, you can, using MacroMate’s popular text editor TextMate. The purpose of this post is to get you up and running, so you can write your articles from TextMate, and publish them to your blog with a couple clicks.

To get started, you need to ensure that you have the “Remote Publishing” option turned on in the Settings → Writing section of your blog. You need to check the box to the right of XML-RPC, as shown in the following screenshot.

Before we can start blogging from TextMate, we have to set up a config file with the necessary information for TextMate to connect to WordPress. To access the config file, navigate to Bundles → Blogging → Setup Blogs as shown in the following screenshot.

If you’d like to be able to post to multiple blogs, you can set up each one on a different line, and you’ll be able to type in which blog will be posted to each time.

At this point, make sure you save the configuration file, or you won’t be able to connect.

The next step we’ll take is to take a look at the formatting required by TextMate to assign all the meta-data required by WordPress (i.e. Title, Categories, Tags). The best way to do this, is to download one of your current posts and take a look at where everything goes. To download a post, you need to navigate to Bundles → Blogging → Fetch Post. TextMate will connect to your server and assuming everything goes well, you’ll get a dialog box showing the posts that are currently on your blog similar to the following:

Pick any one of your posts to take a look at, one that has a lot of content is good, so that you can get a good feel of how TextMate will handle it. I’ll go with my jQuery Tutorials post, to illustrate what some of the tags do.

The tags at the top of the article, as I mentioned, will be used for the meta-data of the post, and won’t appear in the post itself. Let’s go through them one by one, and talk about what they do.

Type: For our purposes, since this tutorial is geared towards WordPress, will always be the same – “Blog Post (HTML)”. You can copy and paste this value when you create a new post, or type it in just like it appears (“Type: Blog Post (HTML)”)

Blog: This is which blog you’d like to publish the article to, and it should be the same thing you called your blog when you edited the config file. If you are posting to multiple blogs, make sure you fill this in. Otherwise, you can skip it and TextMate will automatically add it when you post it.

Link: You can, and should omit this tag when you write a new post (you can leave it there if you’re updating a post). If you fill something in, you’re running the risk it will conflict with the link structure you’ve set up for your blog.

Post: You should omit this tag when writing a new post. It’s the number of the post that you’re writing/editing (including comments). If you change it, you could mess up your WordPress database.

Title: Pretty self explanatory, this is the title of your post. If you omit this, your post won’t have a title, which can cause severe problems depending on how your theme was written. Besides, you want your posts to have a title, right?

Slug: If you want to specify a special “URL-safe” name for your post, you can use this tag, otherwise, omit it and WordPress will automatically generate it based off of your title.

Keywords: These are what WordPress calls “tags”, you can put as many as you want (up to 255 I believe). This isn’t a required tag, but they’re good for SEO (Search Engine Optimization).

Status: This can be set to either “publish” or “draft”, but can be omitted if you’d like (It will default to “publish”)

Date: Unless you want to specify a date other then the one you publish it, you can use this tag, otherwise, it’ll default to the current date/time.

Pings: This is an optional tag and defaults to “On”, if for some reason you want to disable Pingbacks and Tracebacks, you’re welcome to include this tag and give it the “Off” option.

Comments: This is also an optional tag and it defaults to “On” as well. If you don’t want to allow comments on the post for whatever reason, you can include this tag with the “Off” parameter.

Category: This is the same as WordPress Categories, you can include multiple (or no) categories separated by commas.

That about sums it up. TextMate is an incredibly powerful way to blog, because you have complete control of the HTML of your post, without having to use the WordPress web editor. If you have any questions, feel free to contact me by email: josephmc…@me.com or on Twitter: @mclaughj and I’ll be happy to help you as best I can.

MarsEdit too featured packed? I have to disagree, one of the best things about MarsEdit is that you can get away with just writing your code by hand, as I would guess you would be with TextMate, but there is always the option to make use of MarsEdit’s incredibly powerful features that may be overlooked by some. But, you don’t have to use them, or really notice them. MarsEdit’s interface is super simple.

What I was referring to is that there are times when I try to blog in MarsEdit, and I just see way to much. Sometimes I just want to see the text and the code. Your right – In the end, just like TextMate, MarsEdit is a text editor, but TextMate has more functionality then “just a text editor.” I can code a web site, and write a blog post in the same application. You can’t do that MarsEdit, unless you want to code a whole site in MarsEdit! I still use, and love MarsEdit, but this is a good alternative.

The great thing about blogging in TextMate, aside from it’s simplicity, is the great syntax highlighting so you can do complex things in your posts. To see what I mean, check out this post by my dad, Michael McLaughlin: Data Normalization

There’s a ton of content there, with some nice jQuery content sliders and such. If I was to approach writing something of that scale in MarsEdit, I would be very easily lost. That’s why I think TextMate is a good solution.

Don’t get me wrong, I’m not bashing on MarsEdit (I use Blogo for some of my posts), I just think there is definitely a place to use TextMate.