vdegenne
vdegenne

Reputation: 13270

website folder layout

I'm not going to ask what is the best way to ...? since they might be several ways to do it, I just want to know from your experience how to manage folders and files when starting to build a website ? (note: I'm not english native that is why I request here, I can't find right places to be answered).

I've been coding for years but always on my own and I never share about how people structure their website before.

As an information, I'm making a structure file at the root of my website, struct.php that contains the common layouts shared by the many pages in my website.

If the user types http://mywebsite.com/folder/ it requests the index file of the requested folder which just contains the 'struct' file importation, for the other variable parts like the metadatas of webpages, I'm creating a folder named meta which contains a file for any type of data (.title, .description, .keywords) and of course the struct file is fetching the content of these informative file and display them in their appropriate place in the document.

I feel comfortable with that structure cause it's been a long time using it. But I'd really appreciate it if you were giving some advices or some useful links and/or tell me how you manage your own website.

Upvotes: 7

Views: 3908

Answers (4)

SW4
SW4

Reputation: 71140

See:

http://www.warmforestflash.com/blog/2009/10/folder-structure-and-project-organization-best-practices/

What are your tips for best practice for web application structure?

http://www.networkclue.com/internet/HTTP/website-best-practices.aspx

http://www.grouppolicy.biz/2010/07/best-practice-active-directory-structure-guidelines-part-1/

There are no strict rules- only widely perceived 'best practice', which depend on the scope and nature of your site.

Typically it is good to structure your directories around core content, spreading outward to subcontent areas in order of magnitude (number of files for that type of content). Typically as much as anything it helps navigation when editing your site, as much as anything.

Its usually best to have dedicated folders for different types of content, so Javascript (/js), CSS (/css), images (/img) etc. With your scripts (html, php or otherwise) then served in a structure as befits their purpose/quantity.

Dont forget that URLs dont then have to reflect folder structure- I would suggest you lay your directories/folders out in a way that is ordered for someone creating/maintaining the site, more human readable locations can then be handled in .htaccess.

Upvotes: 1

lc2817
lc2817

Reputation: 3742

When you develop web pages, most of the time you use a framework.

The framework generally suggest you or urge you to use a certain folder layout that might be wise to be followed.

So, the programmer doesn't really have the choice in terms of layout unless he builds his website from scratch without any framework.

Upvotes: 0

tereško
tereško

Reputation: 58444

This is the my way of structuring the page :

application_name
  - views
  - controllers
  - modules
  - templates
  - config
  bootstrap.php

framework
  // not important

public // this is the DOCUMENT_ROOT
  - assets
      - javascript
      - css
      - images
  - uploads
  index.php
  .htaccess // if apache 

Upvotes: 4

Jonas m
Jonas m

Reputation: 2734

Like your saying yourself, no one can tell what is the best or not, since this is a very variating procedure. Yet, you can always make better organization. Usually my file structure looks like this.

Root
 -Lib
    -Js //Here goes my Javascript libaries, like Jquery
    -Php //Here foes my PHP libaries (If i have any)

 -Modules //My modules for my page, this could be page controllers, article systems ETC!
    -Pages
    -Articles
    -Etc, etc

 -Templates //My template files
   -Modules //Templates for my modules
      -Pages
      -Articles
      -Etc, etc
  index.tpl //Other templates

-Init //This would contain database handlers etc.

.htaccess
index.php

I hope to see other examples too, maybe i can organize my structure better too ;)

Upvotes: 0

Related Questions