fckeditor

Comprehensive SEO Tutorial: Optimize your Drupal 6 site to be indexed well by search engines

After primarily working with Drupal 5, I wanted to update my SEO skills for Drupal 6 and went through a bunch of tutorials to sum up all the steps and modules required to make a Drupal 6 site ready to be found by all major search engines.

  1. The one main requirement is to enable clean URLs. That option can be found at admin/settings/clean-urls
  2. Secondly, install and configure Pathauto and Token. Pathauto automatically creates nice-looking paths when creating nodes. Token isn't necessarily required, but a nice addition to use variables in your paths.
    Once you've configured Pathauto and are satisfied with how your URLs end up looking, configure Pathauto so URLs don't change if you decide to change the title of a node in the future. You can find that settings under /admin/build/path/pathauto under General Settings / Update Action.
  3. Next, download and configure the Meta Tag module. This module allows you to configure global and node-specific description and tags. The Meta Tag module is actually called nodewords.
    Note: I'm using FCKEditor 6.x-1.3-rc3 and nodewords 6.x-1.0-rc1, which don't play well together when creating a new node. My fix / workaround was to disable FCKEditor on the "New Story" page completely and open it in a popup.
  4. Then, install the Global Redirect Module. This module makes sure that trailing slashed at the end of URLs are removed. More importantly, it fixes the problem that your URLs are accessible via your URL alias and the node/xxxnumber structure. In general, having duplicate content can decrease your search engine ranking.
  5. Install the Page Title module. This module allows you to manually set the page titles of nodes. In the eyes of a search engine, page titles represent one of the more relevant characteristics and will increase your search engine ranking.
  6. Modify your .htaccess file to always redirect to www.yourdomain.com, even if visitors come to yourdomain.com. You can find the rewrite-rules in the .htaccess file, you just need to modify them with your domain name and uncomment them.
  7. Optimize Drupal's robots.txt file. This file defines the rules about what folders of your site can be accessed by search engines. Here's a great tutorial with several modification suggestions: http://tips.webdesign10.com/robots-txt-and-drupal. Once you're done, upload your robots.txt file and verify that it's structured correctly with this Robots.txt Validator.
  8. Finally, make sure your theme is XHTML compatible. Make sure your DOCTYPE declaration is suitable for your needs. I decided to make my danielhanold.com compatible with XHTML 1.0 Transitional, as the Strict declaration doesn't allow to set the "_target" attribute. You can test the validity of your document at the W3 Validation Tool.

There are quite some steps involved to get your content indexed well by search engines. However, if you spend all this time creating great content, I think it's worth the time optimizing your site to be "indexed" the best it can.

Source code highlighting using FCKeditor and GeSHi for Drupal

For the setup of this site, I knew that I needed a good way to display source code in stories. I assumed that Drupal would already have a good way to deal with source code in a post, but I found out that this required quite a lot of manual configuration. In addition to just displaying source code nicely, I wanted to be able to use source code in FCKeditor.

During my research, I came across a module called GeSHi Filter, which was exactly what I was looking for to display source code. This module integrates the third party PHP library GeSHi (Generic Syntax Highlighter) into Drupal. Installing this module was straightforward, except for the fact that the readme didn't mention that I needed to activate the filter in Drupal's input filters.

GeSHi takes care of displaying source code within the <blockcode> tag. Unfortunatley, using this tag in FCKeditor is tricky.

In order to use the <blockcode> tag in FCKeditor, one needs to switch to the source view. In that view, you can enter the source code you'd like to display in the post, and GeSHi will format it nicely once the node is submitted.

There's 2 caveats:

  1. In order for FCKeditor to not screw up the code after switching back to rich text editing mode, the following line needs to be added to fckeditor.config.js:
    FCKConfig.ProtectedSource.Add( /<blockcode language[\s\S]*?<\/blockcode>/gi  );
  2. According to the FCKeditor documentation, protected code is not being displayed at all in rich text mode. However, that code will be displayed when viewing the node.

Unfortunately, I wasn't able to find a better way to integrate the two. This integration works for now, but I hope that the a future release of FCKeditor will offer a better method for source code highlighting.

Syndicate content