John
John

Reputation: 177

HTML root directory?

I'm creating a website and I'm trying to make the url as small as possible and optimize my root directory with as few sub categories as possible. I know that long urls are bad for SEO. Currently, my website has the following menus/pages.

-Home Page (index.html is in the root directory which is good)
-News  (news.html is currently in the news folder/news.html)
-Videos (videos.html is currently in the videos folder/videos.html)

So my question now is, when someone visits my home page, they get www.mysite.com which is good but if they visit the news page, they get www.mysite.com/news/news.html or /videos/videos.html

Should I put the news.html and videos.html in the root directory where index.html is to make the url shorter (www.mysite.com/news.html)? Do most websites put their news.html in the root directory with the index.html? I'm noticing that most websites put it in the root directory but I'm not sure.

Upvotes: 2

Views: 2662

Answers (4)

Enrico Eusman
Enrico Eusman

Reputation: 97

I put all my webpages in my root directory. Unless it's an include like a footer, banner, menu etc. or a function. And maybe take a look at URL rewriting if you want to keep your folder structure.

On top of that, you can also remove the .html/.php extension at the end (when typing the address in the browser. Just open your .htaccess file and add this:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\.html$ /$1 [L,R=301] 

Hope this helps.

Upvotes: 1

Ryan
Ryan

Reputation: 3936

Long URL's aren't typically bad for SEO. What you want is good structure, which is what you seem to want to achieve. It looks like you haven't come across the concept of URL re-writing yet, this is very helpful and removes the need for a complex nested folder structure on your server.

In your case, I would suggest a URL structure on the lines of this:

/ (home page)

/videos (video listing page)
/news (news listing page)

/videos/title-of-a-video-here (example of a single video)
/news/title-of-an-article-here (example of a single article)

Upvotes: 3

Adam
Adam

Reputation: 5246

You could simply create an index.html in each of your sub-directories (news, videos, etc). This will allow the web server to serve the index.html at the root of each of those sub-directories.

A better way to do this is to use some sort of routing mechanism as provided either by your web server or web framework. Apache mod_rewrite can be used for Apache servers, but I think there might be more modern approaches to this as well.

Personally I user the $routeProvider that AngularJS provides to map url to file resources.

Do some research on routing and url rewriting for the framework or web server you are using.

One final note: If SEO if a top priority you may want to read the Google Webmaster docs on urls.

Upvotes: 2

netrox
netrox

Reputation: 5326

Why not just rename news.html to index.html and every time www.mysite.com/news is accessed, it automatically gets index.html?

Upvotes: 2

Related Questions