Currently Ihave the page made for desktop.. But I need to know what I do after i make the site for mobile.. There will be an own folder for the mobile but what will be the code for mobile view of the site, a code that goes automatical depending if the user has mobile or desktop. If desktop site remains but if mobile it changes to mobile.. is this easy code for google to separate and understand the 2 different sites is also important for me to know as i want it optimized.
First of all, unless you're doing something very specific with the mobile solution, this is not the right way to do it. What you do is create a responsive design, which changes based on size of the viewport, regardless of what device it's viewed on. Having different sites based on device is a maintenance nightmare, and usually not worth it in any way. Create a proper site instead, where the exact same pages are shown, just with different CSS.
You should give PoPS a best answer for that, or at least a like. The days of the m. subdomain are over with a properly designed site. Most themes do this automagicly now, well, for WP, it has been a lot of years since I have touched Joomla or Mambo.
Yeah, the notion of two separate sites was NEVER a good idea in the first place, and has no place in the age of modern responsive layout. If you even NEED to think in those terms there is probably something horribly wrong with your existing desktop design such as a lack of semantics, graceful degradation, separation of presentation from content, or a content FIRST approach to development using progressive enhancement. It is also therein likely that the desktop layout is also an accessibility train wreck. Though without seeing the site in question that's hard to say just how badly you've painted yourself into the corner with broken methodologies and "not viable for web deployment" concepts -- it's just that by your even asking the question the way you did, it's highly likely that's EXACTLY what you've already done. Although if it's anything like that holkapolka disaster you were asking about a month ago... everything I just said times a thousand.