9

My question is simple and may be very basic. What is the best way to convert HTML pages to Laravel.?

In HTML pages the links are like <a href="about-us.html">, we have to convert it to <a href="{{ URL::asset('about-us.html')}}"> for Laravel.

Now i am manually editing entire HTML code to achieve it. Is there any short way to do it.?(i used replace all in CodeIgniter) Or What is the best way to avoid this overwork? Any other workflow between designer and programmer?

Note: Please comment here if you dont understand this question well. I will edit it.:)

1
  • 1
    There is no reason to do that. Your HTML pages should work even without Laravel generating the URLs. The only benefit you get from changing them is that it will use Laravel's routing system, but since your HTML pages are just that and served to the client, all you need to make sure is that the assets are retrievable. Commented Sep 28, 2013 at 7:58

2 Answers 2

17

The easiest way is,

  1. Copy all HTML files, and paste them into the view folder.

  2. Change all files extensions from .html to .blade.php (eg. about.html to about.blade.php).

  3. Remove the '.html' from all anchors href, so <a href='about.html'> will be <a href='about'>. (Just replace .html with "" ).

  4. Copy all other files/folders (js folder, CSS folder, image folder, etc) from the root folder to the public folder.

  5. Create a route for your static pages. You can create a route for each page or you can create a single common route for all pages, like this.

     Route::get('{page_name}', function($page_name)
     {
         //
         return View::make('frontend/'.$page_name);
     });
    
  • It will take only 5 minutes to convert a complete 5-page static website.
Sign up to request clarification or add additional context in comments.

Comments

3

There is no way to do this without editing each and every page.

Laravel is based on Routing. So you can't convert your link to,

<a href="{{ URL::asset('about-us.html')}}">

Note the about-us.html. Instead of this you should do this,

First make a Route in app/routes.php

Route::get('about', function()
{
    return View::make('about');
});

Then save your about-us.html file as about.blade.php in app/views.

And you can make the link like this,

{{ HTML::link('about', 'About Us') }}

For better html conversion, see the HTMLBuilder API here.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.