5 Steps for Building a SEO-Friendly Flash Site Using SWFObject and SWFAddress

In this post I outline what USED to be the best way to build a Flash site that was SEO-friendly. It would serve Flash to the people who had Flash, HTML to the people who could only support HTML, and would allow HTML to be indexed by search engines, and wouldn’t have separate URLs for your Flash and HTML sites. It was beautiful.

However, the landscape has changed. Googlebot now indexes BOTH the Flash AND the HTML in SWFObject. The big problem this causes is that Google now gives results with direct links to your SWFs, which can completely mess everything up — I wrote a post that explores the problems presented by Google’s ability to index Flash if you want to read more. In a nutshell, however, I personally have come to the conclusion that although the method I describe below is not IDEAL, it still offers the best way to build all-Flash sites that will get properly indexed and will most often present the correct links in Google results.

So without further ado, here’s how to go about building a SEO-friendly Flash site using SWFObject and SWFAddress.

  1. Use SWFObject
    If you’re not already using the latest version of SWFObject, you should be. Adobe has now announced that it is supporting SWFObject specifically. The beauty of SWFObject is that it allows you to serve Flash to people who can support it and (X)HTML to people who can’t. Also, search engine crawlers index the (X)HTML alternate content you serve, meaning that if you put your content in there, it will get indexed.
  2. Create HTML pages for each of your flash pages
    For each of your Flash pages (home, about us, contact us, etc.), create an HTML page that mirrors its content. That means all the text, all the links, all the pictures, etc. The HTML page doesn’t need to be pretty, but it should semantically reflect the importance of the content on your Flash page (that means have headings, have lists, have paragraphs, use proper links, etc. This will allow search engine crawlers to make proper sense of the content on the site. Also, if you want to make your Flash site mobile-friendly, then make these HTML pages pretty :D
  3. Use SWFObject and multiple Flash files to hide the content
    So you have all these pages, but you don’t want anyone who can support Flash to SEE them – only search engines. That’s where SWFObject comes in. On each of these HTML pages, you will use SWFObject to embed the same Flash file, but have the non-Flash content reflect the HTML you built.
  4. Use SWFAddress and deep linking to direct Flash users to the proper content
    Like SWFObject, if you’re not using SWFAddress, you probably should be. SWFAddress allows you to read information from the URL and then use that within your Flash. The most common reason for doing this is to be able to do deep linking in Flash. I will write some tutorials on how to use SWFAddress in the future, but for now you should download the example files and work through them. Using SWFAddress, you can use #anchors to define where in your Flash you want to go. So if you go to “www.mysite.com/index.html#aboutUs”, you can have SWFAddress load up your “About Us” section. The beauty of this is that search engines ignore #anchors so they won’t get confused and mess up indexing on your site.
  5. Add a JavaScript call using SWFAddress to direct your Flash to the right section
    At this point you’ve got multiple HTML pages and the ability to deep link in Flash. Now you need to direct users who come from a search engine to the right content within your Flash. All you need to do is call SWFAddress from JavaScript and update the page URL. Since your Flash is set up to use SWFAddress, it will read the update and take the user to the proper section.

All those steps are a little abstract, so here’s a more solid example:

Let’s say I’ve got a website with three pages: a “Home” page, an “About Us” page , and a “Contact Us” page. I’ve built this website in Flash with only one Flash file called “main.swf”. Now I want to make sure that this site is search engine optimized.

First thing I do is make sure that I embed the page using SWFObject. Since this first page will be my “Home” or index page, I create a page called “index.html”. At this point, my index.html code will look like:

<!-- Start swfobject code -->
<script src="swfobject.js" type="text/javascript"></script>
 <script type="text/javascript"><!--

var flashvars = {};

var params = {};
params.wmode = "transparent";

var attributes = {};

swfobject.embedSWF("main.swf", "flashContent1", "760", "420", "9.0.0", "expressInstall.swf", flashvars, params, attributes);

// --></script>
<!-- end swfobject code -->
<div id="flashContent1"></div>

Now I will create pages just like the page above for all my interior pages. So I will have three HTML pages “index.html”, “aboutUs.html”, and “contactUs.html”. Once those pages are built, I want to take all the content from inside my Flash file and add it to the html page. For example, the “aboutUs.html” page would look like this:

<!-- Start swfobject code -->
<script src="swfobject.js" type="text/javascript"></script>
 <script type="text/javascript"><!--

var flashvars = {};

var params = {};
params.wmode = "transparent";

var attributes = {};

swfobject.embedSWF("main.swf", "flashContent1", "760", "420", "9.0.0", "expressInstall.swf", flashvars, params, attributes);

// --></script>
<!-- end swfobject code -->
<div id="flashContent1">
<h1>About Us</h1>
Here is a bunch of information that I've copied and pasted from my Flash file. It's all the content from my About Us page.
<ul>
  <li><a href="home.html">Home</a></li>
  <li><a href="aboutUs.html">Home</a></li>
  <li><a href="contactUs.html">Home</a></li>
</ul>
</div>

I’ve now got three files with HTML content within them that mirrors my Flash. This means that Googlebot can now see my content. However if someone searches for an item that appears on my About Us page and clicks on the link in Google, they’ll be taken to “www.mysite.com/aboutUs.html” and will see my Flash. The only problem is they’ll see my HOME page in Flash, not my About Us page. That’s where SWFAddress comes in.

First, I have to set up SWFAddress in my Flash file. NOTE: You should always build your site from the beginning using SWFAddress to navigate your Flash. It’s a HUGE pain to try to go back and retrofit your site to work with SWFAddress, but it’s pretty easy to build your site to use SWFAddress from the beginning. Either way you go, you will add ActionScript which looks similar to this:

// SWFAddress handling
import com.asual.swfaddress.*;
function handleSWFAddress(e:SWFAddressEvent) {
try {
if (currentFrame == 2 &amp;&amp; e.value == '/') {
play();
} else {
gotoAndStop('$' + e.value);
}
} catch(err) {
gotoAndStop('$/error/');
}
}
SWFAddress.addEventListener(SWFAddressEvent.CHANGE, handleSWFAddress);

See the “CS3″ example inside the SWFAddress download in order to see how the above script would navigate you to the sections in your site (I personally use a different, more complex way but that’s just me). In any case, now the Flash is set up that if I go to “www.mysite.com/index.html#/aboutUs/” it will show the about us section. Deep linking is working.

However, what happens if a person goes to “www.mysite.com/aboutUs.html”? SWFAddress looks for information following the “#” so it doesn’t know that it has to go to the About Us section. You do this by adding updating SWFAddress using a call to it in your javascript. The code for this is really simple:

SWFAddress.setValue([link value]);

So your About Us page code becomes:

<!-- Start swfobject code -->
<script src="swfobject.js" type="text/javascript"></script>
 <script type="text/javascript"><!--

var flashvars = {};

var params = {};
params.wmode = "transparent";

var attributes = {};

swfobject.embedSWF("main.swf", "flashContent1", "760", "420", "9.0.0", "expressInstall.swf", flashvars, params, attributes);

SWFAddress.setValue("/aboutUs");

// --></script>
<!-- end swfobject code -->
<div id="flashContent1">
<h1>About Us</h1>
Here is a bunch of information that I've copied and pasted from my Flash file. It's all the content from my About Us page.
<ul>
  <li><a href="home.html">Home</a></li>
  <li><a href="aboutUs.html">Home</a></li>
  <li><a href="contactUs.html">Home</a></li>
</ul>
</div>


And you’re done! This looks more complicated than it actually is. Using SWFObject is extremely straightforward. SWFAddress is a little more poorly documented, and relying on SWFAddress updates to navigate your Flash can be a little awkward at first, but once you get the hang of it, it becomes a really nice, elegant way of working with site content. I’ll post a tutorial on working with SWFAddress soon, but for now, hopefully this will get you moving on the path toward search engine optimized Flash sites!







46 Responses to “5 Steps for Building a SEO-Friendly Flash Site Using SWFObject and SWFAddress”

[...] In the past, you could use SWFObject to embed your Flash and it would present the Flash file to people who could support it (people with the correct Flash plugin) and it would present alternate (X)HTML to people who COULDN’T support Flash. In the past, this also included Googlebot. So if you set up alternate (X)HTML, Googlebot would index that and if you built it right, your Flash pages could have nearly the same ranking as regular HTML pages (because Google was seeing HTML). This allowed you to build Flash sites normally, then build a bunch of alternate HTML pages that had the same Flash embedded, write out their content in HTML, use deep linking to have each individual page go to the correct “page” within Flash, and nobody was the wiser — Google indexed your content and people clicking on Google’s links would see the correct Flash. You can click here to see my tutorial on how to build a site this way. [...]

TheCosmonaut » Blog Archive » Flash Indexing on Google, Revisited added these pithy words on Nov 09 08 at 12:11 pm

The trick, if there is such a thing, is variety. Make certain you collect a steady and varied collection of links

deep links added these pithy words on Jan 16 09 at 3:19 pm

[...] 5 Steps for Building a SEO-Friendly Flash Site Using SWFObject and SWFAddress [...]

How to Make Flash SEO-Friendly « DigitalDay Break — Web Design News added these pithy words on Feb 07 09 at 11:00 am

Seo seems so mystrious but actually it isn’t.

web7x24 added these pithy words on Feb 16 09 at 4:37 am

[...] these or these original 5 pointers for SEO and [...]

Flash SEO - introduction « FlashWorks added these pithy words on Apr 16 09 at 1:59 pm

Nice post, but take it from someone who has been doing search for awhile – anyone who thinks SWFAddress is a good idea for search is kidding themselves and you

Jason added these pithy words on May 07 09 at 6:15 am

Unfortunately it looks like your comment got cut off — I’d love to hear the rest of what you were thinking…

Bear in mind: I’m not talking about using SWFAddress specifically for SEO – SWFAddress in this scenario is used to ensure that the Flash content on any of the search engine optimized-pages is consistent with the (X)HTML content. In a nutshell, you want users to be able to search for a keyword, find it as on your website, click through, and then see that keyword in context; SWFAddress makes that type of deep linking possible without requiring you to build multiple SWFs.

Eric Oliver added these pithy words on May 07 09 at 8:47 am

Dude!! You read my mind! I’m not the flash expert and was bugging on that for weeks!! Thanks for sharing this great info! Congrats on your website!

Cheers!

SEO Packages added these pithy words on Jun 11 09 at 2:40 pm

My pleasure! Hope it’s helpful and let me know if you have any other questions.

Eric Oliver added these pithy words on Jun 11 09 at 2:52 pm

Sorry but using SWF on your site, creates a lot of scriptcode,what makes the keyworddensity of your page drop too much. I did this a while ago and dropped from page 1 in google to page 8… Not funny…

Goedkope Website added these pithy words on Jun 22 09 at 3:53 am

@ Goedkope – I’m really surprised you had that big a drop — you got that much of a drop in page rank while still providing alternate HTML content? Your alternate HTML content should do a lot to balance out the keyword density of your page.

That said, your point is valid: script code can affect keyword density. I would argue that if you’re using Flash on your site, you should have a compelling reason to do so — compelling enough that what you might lose in keyword density, you gain in external links. But of course, that gets us into the discussion of whether you should be using Flash in the first place, whereas this post is more about what you can do to make your Flash more search engine-friendly (whether you should be using it or not :D ).

Eric Oliver added these pithy words on Jun 22 09 at 9:25 am

I wasnt aware the there were SEO friendly sites with Flash. I guess I have a lot to learn. Thanks for the lesson and the coding. Will this work on all Flash sites?

Thanks

Las Vegas Real Estate Club added these pithy words on Jun 27 09 at 1:09 pm

Yup this will work on all Flash sites, but bear in mind that this is all about making Flash MORE search engine friendly; you’re still at a disadvantage when you do all-Flash sites. ;)

Eric Oliver added these pithy words on Jun 28 09 at 10:48 am

SEO for flash is terrible, I have a flash site about ceramics, Google webmastertools indexed it with all keywords from a different site for construction building or so, Don’t use flash, people say Google can read within the SWF’s but if I see this mistake with my ceramics site, I guess they can’t.

CMS Website Joomla added these pithy words on Jun 30 09 at 10:16 pm

That’s why you should follow the steps listed above — they will dramatically improve your Flash SEO. On its own, Google’s indexing of direct SWF files is spotty at best (you can read more about Google’s indexing of Flash on my previous post).

Eric Oliver added these pithy words on Jul 01 09 at 7:18 am

hi Eric,

Thanks for such wonderful article/tutorial. My question is if the XHTML alternate content mirrors the flash content, wouldn’t the robot consider it as duplicate content and ban your site? Do you think that creating a full xhtml alternate site can balance the keyword density decreased by flash scripting?

Thanks again for sharing this valuable information…

Daniel Wind added these pithy words on Sep 11 09 at 1:14 pm

Hi Daniel!

In all testing that I’m aware of, the way that the robots index Flash is different enough from the XHTML alternet content that the bot does not consider it ban-worthy. It seems that at this point, Google is intentionally indexing both the Flash AND the XHTML and is not penalizing sites that do both. In my opinion, the XHTML alternate site can do a LOT to balance the keyword density (depending, of course, on the content that you post). That said, you should not build an XHTML alternate site that is purely for Search Engines where you’re using a lot of SEO tricks — that does run the risk of dinging you in Google’s results. And although this method will do a LOT to improve the visibility of your Flash sites, it should be understood that Flash sites are still not as search engine friendly as non-Flash. Hopefully, this will continue to evolve and improve :)

Eric Oliver added these pithy words on Sep 11 09 at 1:39 pm

Hi Eric,

I appreciate your prompt response. Keep up with the good work and again, thanks for sharing your experience…

Daniel Wind added these pithy words on Sep 11 09 at 2:24 pm

It’s my pleasure. And as you implement these solutions, please feel free to come back and share your experiences. Flash SEO is evolving all the time and the more we share what we learn, the faster we’ll develop better solutions. Thanks!

Eric Oliver added these pithy words on Sep 11 09 at 2:39 pm

I love you Eric!
I mean it !

I have been browsing the entire web for such advice.

Thanks so much for your work. I really appreciate it. keep up

Ben added these pithy words on Sep 13 09 at 9:08 am

Glad it’s helpful! Please come back and share your experiences as well – Flash SEO is constantly evolving and the more we all share our experiences, the better we’ll all get with it.

Eric Oliver added these pithy words on Sep 13 09 at 9:25 am

I completely agree. will definitelly come back as soon as I get some feedback.

Ben added these pithy words on Sep 13 09 at 9:59 am

Ok I have feedbacks now. The method is working brilliantly. It took few weeks to shows in Google search results but now it’s just perfect we have relevant information showing in the google search.
If you type “wakeup studio” in google. You will get our site (http://www.wakeup-studio.com/) first result which was on the second page few weeks back. And if you hit “show more results” you will get the different pages of the site.
Note that one of the result is the swf itself http://www.wakeup-studio.com/index.swf and google shows part of its content although it is completely messy. there’s a 90%(probably the preloader) that shows in the title of the search result.

Ben added these pithy words on Oct 02 09 at 9:35 am

well i’m not so sure about what i just said it seems that my cache was not well emptied so now it doesn’t show in google’s result anymore.
waiting for some proofs still.

Ben added these pithy words on Oct 02 09 at 9:42 am

Ok after few try of emptying cache and checking out the search results.
I can now affirm that Eric’s method is working.

It is just that our site is not well referenced yet on the right keyword.
For some reason the search I need to make is like this

“WakeupStudio Web Design”

This way I get into the 5 top results and i can see my website pages with their content.

Sorry for the confusion again.

It works !

Thanks Eric

Ben added these pithy words on Oct 02 09 at 10:23 am

Hey there!

I’m glad it’s showing up for you! I was going to say: when I looked at the site, there’s not much emphasizing the keyword “wakeup studio”. One of the perils of introducing more content that Google can see on your site is that it’s possible that links can be more diluted, so when employing this method it’s important to make sure the alternate content you supply is search engine optimized.

In this case, changing the <h1> tag from “Accueil” to “Wakeup Studio”, adding more mentions of “Wakeup studio” into the text content (it’s only mentioned once), making sure that “wakeup studio” is a hyperlink on the page, even keywording & metatagging, etc. would all probably help to some degree.

Also bear in mind that the Flash home page has a lot of interesting content on it. My French is rusty, but from what I can see they’ve got job hiring text, news, references & portfolio pieces, etc. The alternate content should reflect this great content as well – the search engines will love you for it.

Rock on and continue to keep me posted on what you learn!

Eric Oliver added these pithy words on Oct 02 09 at 10:58 am

Hey thanks for the SEO tips.

I’m new to this, it is actually interesting and exciting to see the improvements we can make by just changing few details here and there.

I forgot to mention but I’ve discovered during my testing session that ie7 and some version of flash player(i think it’s 9 and lower) might result in a big crash with swfobject.

So that’s a downside to consider, I managed to correct that bug my way on wakeup studio’s website but i’m not 100% satisfied with that.

What I do is that for ie7 I show a static embed swf and destroy the container for the standard swfobject insertion.

It might not be so good as the client might be downloading twice the same file… i’m not sure how to correct that properly but it’s a quick fix with which i’m quite happy for now.

Cheerio

Ben added these pithy words on Oct 03 09 at 3:56 am

I hear you. If you like tinkering, SEO is definitely for you – loks of little adjustments all over you site can have big effects overall, and I enjoy the process fun experimenting and trying things out.

Regarding SWFObject – in your code, I notice you’re linking to a local copy of SWFObject. I suggest that you link to the Google Code repository of SWFObject – that way you won’t have to host the file locally, you take advantage of Google’s speedy servers, and it’s ensured that you will have the most stable version of SWFObject. To do this, simply add the following code before your SWFObject embed in your header:

<script type=”text/javascript” src=”http://ajax.googleapis.com/ajax/libs/swfobject/2.1/swfobject.js”></script>

Doing this should eliminate any crashing issues you’re having (I’ve been using this on sites for over a year with no issues at all on all platforms).

Also, I notice you’re embedding the SWFObject script in the body of your page. I’m not sure if you’re doing this as part of the IE7 switcher you’ve built, but I’ve found that embedding SWFObject in the body can be quirky. Best thing to do is put it in your header and then indicate the DIV you want to replace in the script (check the source at http://www.invincibletiger.com/ for an example).

Happy coding!

Eric Oliver added these pithy words on Oct 03 09 at 10:01 am

Hey Eric,
Thanks for the advices on the crash.
I tried what you said, I put the example there:

http://wakeup-studio.com/recrutement2.html

Unfortunately I still had the same problem on this config(ie7, flash player 10).
Now what I understood by testing on theinvicibletiger.com is that the flash player was not installed on the IE version of my colleague.

Therefore there is no issue .
It’s just that I thought once the player is installed on firefox it is also installed on IE but I was wrong assuming the latter.

Once the player installed it was working perfectly.

Thanks again Eric.

Ben added these pithy words on Oct 08 09 at 1:40 am

Hi this is a nice looking blog, I was just searching for this the other day. Glad I finally found what I wanted.

Unlock Wii added these pithy words on Nov 30 09 at 2:32 am

[...] is the best I could come up with for that TheCosmonaut 5 Steps for Building a SEO-Friendly Flash Site Using SWFObject and SWFAddress maybe someone else knows another way that is a little simpler [...]

adding html on top of flash added these pithy words on Dec 16 09 at 6:11 am

Use the developer plug-in for Firefox and visit a few well ranking flash sites, disable JS and you will see what they are doing behind the scenes.

Mike Law added these pithy words on Jan 19 10 at 5:13 pm

[...] by search spiders like traditional HTML websites. If, you choose to use a full flash site here are 5 Steps for Building a SEO-Friendly Flash Site from TheCosmonaut that will help to improve SEO [...]

Grow Your Business Through Events » Blog Archive » SOS – Save Our Site: Top 5 Website Faux Pas That Can Cost You! added these pithy words on Feb 01 10 at 1:59 pm

[...] via TheCosmonaut » 5 Steps for Building a SEO-Friendly Flash Site Using SWFObject and SWFAddress. [...]

5 Steps for Building a SEO-Friendly Flash Site Using SWFObject and SWFAddress « Social Media Greece added these pithy words on Feb 10 10 at 2:34 am

I am still a beginner in website SEO and i usually submit to website directories and article directories to boost the ranking of my site. .’.-

Gabriel Walker added these pithy words on May 05 10 at 2:48 pm

Thank you for sharing the information. I found the info really helpful.

building backlinks added these pithy words on May 15 10 at 9:30 am

Have been looking for a straight forward solution like this.

Will help in all my future projects, much appreciated!

Jarome added these pithy words on May 31 10 at 11:51 pm

My pleasure — good luck and let me know if you discover any quirks or improvements to be made.

Eric Oliver added these pithy words on Jun 01 10 at 9:45 am

Hi Eric

Thanks for your solution.

I like your idea of creating an html page for each section of the flash site so that google can fetch the info that is in html.

I have enabled swfaddress on my project which works fine, but when i create a html file for each section and add SWFAddress.setValue(“someValue”); to the swfobject section of the html file, it doesnt go to the relevant section it always goes to the homepage frame.

Do you know what it is i could be missing? Do you set up a folder structure for each html file?

Any ideas would be appreciated.

Thanks

Robert added these pithy words on Jul 01 10 at 9:21 am

@Robert – It sounds like the SWFAddress handler may not be working in your Flash. If you don’t do the setValue command, and you’re just browsing your Flash site, does the URL update when you go from section to section? Also, if you have a URL I can take a look at, I’d be happy to look at it directly…

Rock on!

–eric

Eric Oliver added these pithy words on Jul 01 10 at 9:28 am

Hi Eric

I have set the setValue command and it does change from section to section. I was just trying to replicate your example of creating a page for each section.

If you got to brooke-products.com you will see it working but if you go to brooke-products.com/paMixer.html It doesnt go to the right section.

Thanks for your help.

Robert added these pithy words on Jul 02 10 at 1:21 am

@Robert

Thanks for the links! I see what’s happening: On your paMixer.html page, you’re setting the value to “#/paMixer” — it should be set to “#paMixer” (no ‘/’). With that change, the page works fine!

Eric Oliver added these pithy words on Jul 02 10 at 7:37 am

Eric thanks for getting back to me. You are absolutely right.

How do i get rid of the (/)? The other question is i understand the logic of creating html pages for each section of the flash site, but how do i get to link to the html from the flash movie, e.g. index.html to paMixer.html. Im using frame labels to link to each section of the movie?

Thank you Eric.

Robert added these pithy words on Jul 02 10 at 8:52 am

@Robert

I’m sorry – I had my stuff backwards! It appears that your Flash is set up to process SWFAddress without the leading “/”. The proper format for a SWFAddress URL should be “http://brooke-products.com/#/paMixer” where the “#” is surrounded by ‘/’ characters. This ensures that the URL has proper divisions between all content. So you should revise your Flash so that it expects the “/” before all site sections. Once that’s done, you should be good. I’ve revised my code above to make this clearer.

As for linking to the HTML from the flash movie, you don’t need to. In essence, your paMixer page and your index page will host the exact same Flash file, only the initial page that’s loaded will be different. Since they’re the exact same Flash files, you don’t need to load up any additional HTML. Does that make sense?

Eric Oliver added these pithy words on Jul 02 10 at 9:49 am

Hi Eric

It makes complete sense now, I have implemented this for the whole website. After a week of testing it looks good so im going to give it a month to see if it makes a difference to the search engines in terms of them finding the content.

I have had a look at your portfolio it is fantastic! Very inspiring! Hopefully one day my work can get to that standard. Im learning as3 at the moment, do you have any advice or words of wisdom?

Cheers Eric

Robert added these pithy words on Jul 14 10 at 2:42 am

Great news! I very much look forward to hearing how the site performs. Be sure you’ve got Webmaster tools installed on the site so you can be sure to track exactly how Google is indexing your site.

As for AS3, you’re heading into a wonderful new arena. Transitioning from AS2 to AS3 can seem like a bit of a hassle, since AS3 is a little less forgiving and “forces” you to write things a certain way, but one you transition, you’ll never look back. As for words of advice, I would strongly advise getting comfortable with building, reusing, and extending classes if you’re not already doing so. O’Reilly’s Essential Actionscript 3.0 is a good book for getting a solid footing in AS3. I’d also recommend browsing around NetTuts+ and ActiveDen’s Tumblog for bits of advice, tutorials, and so on.

And thanks for the kind words on the portfolio! It’s woefully out of date now — I have to get on posting some more recent work, but I’m too busy to be working on my own site ;)

I look forward to seeing more of your work — keep me posted!

Eric Oliver added these pithy words on Jul 14 10 at 9:18 am

Leave a Reply