Help - Search - Members - Calendar
Full Version: does it matter? simple or complicated directories
Movable Type Community Forum > Additional Resources > Tips and Tricks
dotpitch
Before rebuilding my site towards MT, I was asking myself if it matters how your directorystructure works, if you ever wanted to change it, or change towards using another blogtool, or not using any of those but making one yourself (allthough this will never be the case). So is it safer to use for instance 1 directory for all the archives, and 1 directory for all the images en flashthings (even it this means a directory with a thousand different images), or can I make the directories as specific as I like? So can I use 2003/june/images/photographs for that 1 picture? I know I can and that it will work because MT together with MySQL keep everything in place. But is it a wise thing to do? Thinking ahead, for things that could happen or go wrong with your installation? smile.gif
nammer
You can essentially do whatever you like, in part by customizing the filename structure in your archives (look in Weblog Config).

This is like true confessions, but here's what I'd do differently if I were installing fresh or starting over. I don't think it's as complex as you envision. smile.gif I'd dirify my archive filenames. This is a great choice to make at the beginning so you don't leave a trail of broken filenames behind you later.

I'd store photos and images I use in entries in folders by year - it's easy to do this when uploading, and it keeps a lot of loose files from floating around. I've never had occasion to go back and retrieve one, so I don't know if I'd do anything other than make them tidy.

I'd store images and photos used in my templates in a separate folder, called something like "common" - while I already do this with images in the designs themselves, I haven't been so good about the buttons and other image links that appear in the sidebar. These change more frequently, so I'd also do a better job of naming them meaningfully after I download them and put them away.

Finally, I already store code snippets and includes in a folder helpfully called "includes" - I use this folder often, so this was a good choice. Keep in mind that any code snippets you have that use MT tags will need to be processed by MT before you use it on your site (if you have your sidebar as a separate file so you can use it on every page of your site, for instance). Just make these snippets into index templates and set the output path to your "snippets" or "includes" directory.

This was a lot of semi-helpful information - the short answer is that MT will support the directory structure you think will work best.

Does that help - sort of?

Donna
dotpitch
Thanks for the advice. Sure it's helping me to understand the structure of a blog. The dirify-thing is nice allthough I don't understand how this can avoid broken links?

But what I still don't understand is this: suppose I set up a directorystructure like I was planning to. Suppose (not a chance at this moment because I think MT is the best choice) that I wanted to export my weblog and import it into another weblogprogram. Wouldn't this kind of structure create problems when importing the data and all of the internal linking? I assume another weblogprogram will not create all those directories for you.

Perhaps I'm being very neurotic about this (among other things tongue.gif ), but I'd really like to know.

Jack
girlie
I think what Donna means by dirifying the file names to avoid broken links is this:

If you name your files using the Entry ID, and you ever have to export and then re-import those entries into a new MT installation, they will all be assigned new Entry ID numbers - causing any links which previously referred to a particular entry by its original Entry ID to now be "broken".
nammer
Yes, girlie is right, and I also meant that now that I have 1100+ posts, if I switched to dirifed names, I'd break all my internal links and all of the external links from other sites to the old filenames.

As for importing to another program later, there would always be some tweaking to be done, but the entry format is the key, not the directory structure - as long as the new program gives you a format in which it wants your entries, and you have a way to export your entries into the format the new program wants, you should be fine. Review the instructions for importing Blogger entries into MT to see what I mean; there are also homemade scripts around this board that show you how people have imported comments from other third-party programs into MT; the format is the key in each case, not where the information is stored.

Since MT gives you a pretty generic export format, you should be okay.

Donna
girlie
Hey Donna, you know what I did when I made the switch during my move to Blogomania?

I first published all the files under the old (entry ID) naming structure, using an individual template that had a META tag in it:

CODE
<meta http-equiv="refresh" content="5;url=<MTBlogArchiveURL><MTEntryDate format="%y%m">/<MTEntryTitle dirify="1">.php">


The tags duplicated the Archive File Template I was planning to use. I rebuilt all the Individual Archives, and ended up with a file for each entry that would point to the anticipated new location for the entry.

Then, I pasted my original IA template back in, changed the Archive File Template to what I wanted, and rebuilt again.

So then, if anyone visited a URL with an entry ID in it, they'd be redirected to the new URL with the entry title in it. smile.gif

It seems like I also remember seeing here a way to use PHP to customize a 404 page that will attempt to locate the new URL for a user. Can't remember where though. Maybe I'm thinking of Kristine's solution, but I thought there was a different one as well.
dotpitch
OK, I think I got it into my head now. I think smile.gif

On this same line I have another, little, question.
I am absolutely unfamiliar with PHP, allthough I'm going to use MySQL as database. For future handy little codings and stuff (and perhaps even a personal interest in PHP), do you think it's an option to use .php as a standard filename extension instead of .html? I notice that sometimes on other blogsites. Or can I use PHP tricks all the same, even when I used .html?
kjmck
Would I be correct in thinking that if I wanted to change from BerkeleyDB to PostgresQL and dirify my entries (still not quite sure what that means) that I could export the blog, make the structural changes I wanted, then re-import the entries?

Would they then be re-assigned new names/locations appropriate for the new organization?
girlie
dotpitch - to use PHP in your pages, you'd either need to change your file extensions to PHP, or add this line to an .htaccess file:

CODE
AddType application/x-httpd-php .htm .html


to make your .htm and .html pages interpret as PHP.

kjmck - you don't have to export and reimport your entries to make a change in the file naming structure. You just need to change or add an Archive File Template with the new naming structure, and rebuild your site.

"Dirify" means making the text generated by an MT tag suitable for use in a file or directory name. Some of the things dirify does: make all letters lowercase; change spaces to underscores; convert certain characters; and strip HTML.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.