Search code examples
laravellaravel-4

Convert HTML code to laravel(or any framework)


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.:)


Solution

  • 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.