Skip to Main Content
Perspectives
Digital Transformation

SPA SEO: Single Page Applications and SEO

SPA SEO: Single Page Applications and SEO

The rise in mobile device applications and mobile web usage in general has greatly influenced internet user expectations as to how they want their content delivered. When you’re navigating around in your favorite iPhone or Android app, the displays usually transition smoothly. You rarely get a feeling that a given page is being “loaded” on your device. As a result, an increasing amount of web content is trying to follow suit.

A popular way for a website to emulate a device application is to load content by way of asynchronous AJAX calls, i.e., javascript injecting new content from a server into a page without the entire page needing to be reloaded in the browser.

What are the benefits of SPAs?

In addition to smoother loading, SPA sites have many more benefits (and differences) to consider when comparing to MPA sites (multi-page applications): mobile adaptability, caching, and more. See this new post on the differences between SPA and MPA sites for a more complete breakdown.

Examples of Single Page Applications

A classic example of this is posting a comment on Facebook, where your comment pops up after you submit it, but without the page being reloaded from scratch. Over the past few years this trend has been taken even further, with a notable number of websites now running as Single Page Applications, or SPAs.

Other examples include sites you probably use on a daily basis:

  • Twitter
  • Google Maps
  • Wix
  • Gmail
  • Instagram
  • Github
  • Google Drive

In single page application websites, there is only the initial page load when you arrive at the website. From there, all the different pages within the site are loaded by javascript, commonly with React or Vue.

Looking at a few of these SPA sites or SPA pages confirms that many of these sites strive to emulate the smooth user experience of a good Android or IOS application. This is visible in the way different web pages seem to glide into view, without the laborious process of a page loading that comes with MPAs (multi-page applications).

So why aren’t more of these single page application websites being built? As a developer, I have been in the room when beautiful, single page application demo sites have been vetoed by project and account managers.

The reason why? Issues with SPA SEO – that is, “single page application SEO.”

How Twitter attempted to solve its own SPA SEO problem

Twitter, which has relied heavily on AJAX technology, came up with the idea of javascript loaded URLs to have a ‘#!’ URL segment to make the URL unique to correspond to a given tweeted comment. This became known as the “hash bang” tag and it was far from a perfect solution. Using ‘#!’ in a URL was not in accordance with World Wide Web Consortium (W3C) standards, as it didn’t truly mark the path to a real resource location.

The ‘#!’ also made things difficult for developers since they had to work with these unusual characters in backend development scenarios. Consequently, the hash bang URL was a flop — despite being initially recommended by Google as a quick fix to the SEO issues with javascript.

Duplication: an alternative to hash bangs for SPA SEO

Another more solid solution was to make sure that if a website was being built as a single page application, a complete duplicate site would be created within the same URL to make sure that Google crawlers – working in the background – would index the site pages properly. Again, this was not a viable long term solution. Creating mirror versions of a given live website gave rise to a maintenance nightmare, as code redundancy is the enemy of the web developer (web developers hate redundancy).

How to make a SPA SEO friendly with HTML pushState SEO

Push State is a feature of HTML 5’s History API. In modern browsers, the main window object now has a child history object that enables a user to programmatically move backwards or forwards in the browser history via window.history.back() or window.history.forward() giving the same behavior as if the user were clicking on a given entry in their browser’s history toolbar menu. But particularly relevant for SEO and SPA applications is one of the history API’s methods: pushState.

The pushState method takes three arguments, a data “state” object, a title string, and a url. When the pushState method is called, the url that is passed to it will appear in the browser’s url window.

An example of HTML pushState

So if you’re on https://www.mydomain.com, and call the below pushState method, the browser window will then show https://www.mydomain.com/new-page.html.

var stateObject={some_data:"some useful value"};
history.pushState(stateObject, "new-page","new-page.html");

This is why when you browse a SPA like Twitter it will still appear like you’re opening new pages in the address bar.

Up until recently, the only way that javascript could programmatically change a browser url was to change the window.location object; but this would always result in the reloading of a browser window. But with pushState, the URL magically updates without the page reloading. A pushState-fired URL change can then be followed by an AJAX call that loads new content onto the page, so we have a new URL with new content to match and get crawled and indexed by Google.

Final Considerations for Single Page SEO Applications

Note that the state object you pass into the pushState function can contain useful data that you can use on the new page. There is a limitation to the amount of data you can use in a pushState state object however, as the serialized version must be under 640k. There is also a wise limitation built into pushState that only allows new URLs that are within the current web domain – to prevent spoofing.

If you’re thinking of building the next big web app and are considering SPAs – that’s great! Just make sure you and your developer team understands how to make your SPA SEO friendly.

SEO single page applications Web Development

代做工资流水公司三亚查询个人工资流水泰州工资代付流水制作台州企业流水打印德阳开房贷流水邢台薪资银行流水费用威海个人流水公司天津代办转账银行流水石家庄贷款工资流水 价格宁德流水单代做南通查询银行流水单临沂办消费贷流水南京转账银行流水代办中山企业流水打印模板汕头企业贷流水报价鞍山制作房贷银行流水淮安开日常消费流水苏州购房银行流水代开临沂查企业银行流水滁州工作收入证明样本福州代开公司流水扬州流水报价南阳办对公银行流水深圳签证工资流水报价咸阳银行对公流水办理德阳自存银行流水费用长沙查薪资流水单邢台薪资流水打印深圳办理对公账户流水常州工资代付流水图片遵义个人工资流水 制作香港通过《维护国家安全条例》两大学生合买彩票中奖一人不认账让美丽中国“从细节出发”19岁小伙救下5人后溺亡 多方发声卫健委通报少年有偿捐血浆16次猝死汪小菲曝离婚始末何赛飞追着代拍打雅江山火三名扑火人员牺牲系谣言男子被猫抓伤后确诊“猫抓病”周杰伦一审败诉网易中国拥有亿元资产的家庭达13.3万户315晚会后胖东来又人满为患了高校汽车撞人致3死16伤 司机系学生张家界的山上“长”满了韩国人?张立群任西安交通大学校长手机成瘾是影响睡眠质量重要因素网友洛杉矶偶遇贾玲“重生之我在北大当嫡校长”单亲妈妈陷入热恋 14岁儿子报警倪萍分享减重40斤方法杨倩无缘巴黎奥运考生莫言也上北大硕士复试名单了许家印被限制高消费奥巴马现身唐宁街 黑色着装引猜测专访95后高颜值猪保姆男孩8年未见母亲被告知被遗忘七年后宇文玥被薅头发捞上岸郑州一火锅店爆改成麻辣烫店西双版纳热带植物园回应蜉蝣大爆发沉迷短剧的人就像掉进了杀猪盘当地回应沈阳致3死车祸车主疑毒驾开除党籍5年后 原水城县长再被查凯特王妃现身!外出购物视频曝光初中生遭15人围殴自卫刺伤3人判无罪事业单位女子向同事水杯投不明物质男子被流浪猫绊倒 投喂者赔24万外国人感慨凌晨的中国很安全路边卖淀粉肠阿姨主动出示声明书胖东来员工每周单休无小长假王树国卸任西安交大校长 师生送别小米汽车超级工厂正式揭幕黑马情侣提车了妈妈回应孩子在校撞护栏坠楼校方回应护栏损坏小学生课间坠楼房客欠租失踪 房东直发愁专家建议不必谈骨泥色变老人退休金被冒领16年 金额超20万西藏招商引资投资者子女可当地高考特朗普无法缴纳4.54亿美元罚金浙江一高校内汽车冲撞行人 多人受伤

代做工资流水公司 XML地图 TXT地图 虚拟主机 SEO 网站制作 网站优化