Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

huckleberry
huckleberry
14,636 Points

Adding a new directory after you've installed WordPress.

Ok so I went through LWP track and I got a couple of sites up and running. Fantastic.

I used the one-click install because the other method wasn't covered and why make things difficult when you're learning, right? So when I first went to do the 1click on the one site, I already had stuff in the root directory. It wouldn't install so I removed all that stuff and then did the install. Perfect. So, now how do I go about adding that stuff in?

Is it simply a matter of just adding the stuff back into the root directory? Was the need for the root to be empty only for the time being while WP installs and now I can add any number of other folders in there?

I'm asking because one of the sites is a project/portfolio site and I want a separate directory where I can keep all of my projects which I'll then link to in my posts. It seems rather obvious or intuitive that yes, you can add other folders and directories and that yet, they would go in the root folder, but I just want to make sure before I go in and screw something up. Like, maybe I have to add something inside of the wp-config.php file or something to make wordpress acknowledge it as a new folder and not something unrecognizeable... that seems ridiculous but again, don't know how WP truly functions at its core so *shrug*

Thanks!

Huck - :sunglasses:

huckleberry
huckleberry
14,636 Points

Ok, so... turns out you can. I added a folder within the mysitenam.com folder... where all the WP stuff is -- and then inside of that I put an index.html and its CSS page.

root
    mysitename.com
        WP Stuff
        projects
            css
                style.css
            index.html
    .cache
    logs

I then added a link to that page in a sample post to test it out. At first it didn't work but that's because I pasted the absolute path -- mysitename.com/projects/index.html instead of linking it as a relative path.

What I didn't know is that WP would append the name of my site to the beginning of the link. So when I actually clicked the link in the post I got a page not found because it was trying to open mysitename.com/mysitename.com/projects/index.html

So, I changed the link to projects/index.html and presto... worked perfectly. The problem though wasn't that it automatically appends the sites url to a link, otherwise if you tried to link anywhere else it wouldn't work. The problem was that I didn't keep the http:// there.

Today I learned that when adding a link in your post, don't remove the http:// part of the linking process or else WP will think it's a relative path and append your sites URL to the beginning!

tl;dr

To sum up -- Yes. To have additional pages or resources outside of the WP formatting and all of that, you just add in your subdirectory(ies) and start adding content as you'd normally do as if building your site without WP or any other CMS. To then link to said pages, you can use either the strict relative path, or if you're using the absolute path, make sure to include the http:// part of the url in the insert link tool.

Thanks for the dialogue bro!

Cheers,

Huck - :sunglasses:

1 Answer

Sue Dough
Sue Dough
35,800 Points

Your root directory on your host sometimes has default files. I don't think there would be a need to delete any of them. You can have separate folders for separate sites. I am not sure what you took out. It may be helpful to mention the files you took out. You can install different directories on a server.

huckleberry
huckleberry
14,636 Points

well, not the root root folder on the server but rather the main folder that is the folder that says mysitename.com ... inside there I had the home page and the css folder and sub folders for some other pages I had on there. So I just got rid of all that stuff and my main folder was then blank. No index.html or any of the sub folders. I then installed the WP and that went in there. I didn't realize at the time I could actually install manually to a sub folder. Anyway now it's

Directory

<code> Root mysitename.com WP stuff .cache logs etc... </code>

So, for sub directories to other pages that I want to add that aren't actual WP pages like posts, articles, things like that (for example, sample code that I'm working on, sample web pages or whatnot that I want to link to in a post) I want to know if they can/would go inside of the mysitname.com folder

For example <code>

Root
    mysitename.com
        WP Stuff
        js_projects
        sample_web_pages
    .cache
    logs

</code>

Or would I put those sub folders of the projects and sample web pages that I'm working on directly in the root?

<code> Root mysitename.com WP Stuff .cache logs js_projects sample_web_pages </code>

Thanks for your time :)

Huck - :sunglasses:

Sue Dough
Sue Dough
35,800 Points

What happens if you put an index.html or index.php with something in it and go to mysitename.com/js_projects/index.html ? I think it would work but I am not 100% sure.

huckleberry
huckleberry
14,636 Points

Yeah I wasn't sure either and since all the WP stuff was in the mysitename.com folder, I wasn't sure if putting another folder in there would screw anything up. Thinking about it now though I don't see why it would really. I mean, it's just separate folders and shouldn't interfere with anything else since the only way the site/server does anything is via following paths in the first place and a new folder in there wouldn't interfere with a current path or file/folder location.

Was just worried that it somehow might since it's all a bit new to me with this WP thing ya know?

I'll give it a shot and let you know what's up.

Thanks again :)

Huck - :sunglasses:

huckleberry
huckleberry
14,636 Points

Ok, so... turns out you can. I added a folder within the mysitenam.com folder... where all the WP stuff is -- and then inside of that I put an index.html and its CSS page.

root
    mysitename.com
        WP Stuff
        projects
            css
                style.css
            index.html
    .cache
    logs

I then added a link to that page in a sample post to test it out. At first it didn't work but that's because I pasted the absolute path -- mysitename.com/projects/index.html instead of linking it as a relative path.

What I didn't know is that WP would append the name of my site to the beginning of the link. So when I actually clicked the link in the post I got a page not found because it was trying to open mysitename.com/mysitename.com/projects/index.html

So, I changed the link to projects/index.html and presto... worked perfectly. The problem though wasn't that it automatically appends the sites url to a link, otherwise if you tried to link anywhere else it wouldn't work. The problem was that I didn't keep the http:// there.

Today I learned that when adding a link in your post, don't remove the http:// part of the linking process or else WP will think it's a relative path and append your sites URL to the beginning!

tl;dr

To sum up -- Yes. To have additional pages or resources outside of the WP formatting and all of that, you just add in your subdirectory(ies) and start adding content as you'd normally do as if building your site without WP or any other CMS. To then link to said pages, you can use either the strict relative path, or if you're using the absolute path, make sure to include the http:// part of the url in the insert link tool.

Thanks for the dialogue bro!

Cheers,

Huck - :sunglasses:

Sue Dough
Sue Dough
35,800 Points

Glad to hear you got it all sorted :)