sondr3 / generator-jekyllized

A Yeoman generator for Jekyll to rapidly build sites using Gulp
MIT License
326 stars 35 forks source link

Viewing built site from a custom local server #152

Closed djmtype closed 8 years ago

djmtype commented 8 years ago

While the local dev url is great for development. Sometimes I need to view the production build before publishing or for client review. So, I use MAMP, and dyn just for custom naming.

The url would look something like http://mysite.dyndns.org:8888/my-jekyll-project/dist/ which shows the home page. However, all the asset paths are broken because they're being called from the root directory.

Ideally, is there a task to show a production version, so it can be seen from a url such as http://mysite.dyndns.org:8888/my-jekyll-project/?

djmtype commented 8 years ago

I realize the easiest fix for me is just to point the custom dyn url or alias at the dist directory inside the project folder. However, if I wasn't using a dyn url, that wouldn't be possible because all asset paths would be broken.

The the production build url (served from MAMP) would be something like: http://192.168.1.6:8888/my-jekyll-project/dist/.

djmtype commented 8 years ago

Nevermind, my ask seems more specific to Gulp than this specific generator

sondr3 commented 8 years ago

If I understand it correctly, you want to run your site with production settings and be able to let others view it for you? If you go into tasks/assets.js and uncomment the // tunnel: true, line (it's towards the bottom of the file) and then run gulp --prod it will run your site in production mode and give you a link that others can access outside of your local internet. You'll see the URL in the terminal.

djmtype commented 8 years ago

@sondr3 I saw the tunnel option. It works perfectly. But, my question was more about using my own domain name (set with dyndns) instead and have it pointed directly at the dist directory.

You see, my project sites are served from subdirectories and since all the jekyll assets are served from the root, they are broken. Plus, for client proofing, my own domain is easier to remember than the random string url tunnel serves up each time.

I believe the Generator Webapp had a task built specifically for this kind of thing. I'll look into that. But, don't fret about my question. Thanks a bunch for creating this generator, dedication and help.

sondr3 commented 8 years ago

I'm 99% sure that the generator-webapp generator actually doesn't do that, your setup is pretty unconventional. I'd just install nginx locally and configure your sites using that and rsync the optimized dist folder to whatever directory you want to serve your site from and then point it to that.

However, I highly recommend setting up your own server instead, you have a very unconventional setup otherwise.

djmtype commented 8 years ago

You're right, I amended to generator webapp after the fact.

Regardless, with generator webapp, viewing a production build from anywhere on my local server has the assets in tact because their paths are not relative to the root.

Webapp's asset url example: <link rel="stylesheet" href="styles/main.css"> Jekyllized asset url example: <link rel="stylesheet" href="/assets/stylesheets/style.css">

Sorry, I should've caught this from the start. Easy fix. Workaround for relative paths. Not nearly as smart as using the Inject method though :(