Skip to content
This repository has been archived by the owner on Feb 25, 2021. It is now read-only.

Subdirectory url linking #4

Open
Sananes opened this issue Sep 8, 2017 · 6 comments
Open

Subdirectory url linking #4

Sananes opened this issue Sep 8, 2017 · 6 comments
Assignees

Comments

@Sananes
Copy link

Sananes commented Sep 8, 2017

Hey!

I'm having an issue with url restucturing for subdirectory files, for example:
https://cl.ly/2b2s2P0s3w2I

How do you go about URL rewrite on a subdirectory so it has access to all asset folders?

Apologies for my terrible explanation.

For example something like this would be great:
https://cl.ly/160T143M043H

@aderaaij
Copy link
Owner

aderaaij commented Sep 8, 2017

Hey there! Ah yeah I understand what you mean. I need to have a look at what the most elegant way to solve that situation is. You could always add a variable on every subpage, like - var subdirectory = '../' and use those in the urls of the layout page, if that makes sense. But there might be a better way. I'm going to have a look and will probably report back this weekend!

@aderaaij
Copy link
Owner

aderaaij commented Sep 8, 2017

Ah it seems that all you need to do is add a / before the main assets. So in view/_layout.pug, add a forward slash to both the assets path, so you have /assets/css/screen.css for the stylesheet and /assets/js/script.js for the script.

I'll test if that gives any problems somewhere, but if all is well you should be able to use that!

@Sananes
Copy link
Author

Sananes commented Sep 9, 2017

Thank you so much for answering that so quickly! Yeah you're totally right about using /images/ to point to root directory. the only issue I still find is if you upload the production files to a server in a subdirectory, let's say in this example http://site.com/v2/ the absolute path for images will end up being http://site.com/images instead of http://site.com/v2/images

By the way this repo is fantastic!

@aderaaij
Copy link
Owner

aderaaij commented Sep 9, 2017

Ah yeah that's very true! Actually I remember I once accepted a pull request for just adding a / to all assets, but I ran into the same problem. I guess it would be best to have a relative path based on the path of the index file.

In theory you could also achieve pretty urls by just having all the page files in the templates folder and using a .htaccess file to remove the file extension.

In any way, I'll leave this open until I think of something, or if you have any suggestions they're most welcome.

Thank you for the kind words on the repo! I'm glad to see people using it. I've been using this for quite a while and it's the starter of almost all my projects 👍

@aderaaij aderaaij self-assigned this Sep 9, 2017
@Sananes
Copy link
Author

Sananes commented Sep 13, 2017

Thanks a bunch for all your hard work. I've managed to figure some of that stuff out myself so I will be happy to share this with you!

@aderaaij
Copy link
Owner

Please do! Always open to pull requests!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants