Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML

How to add a separate HTML file for desktop and mobile devices

I have six boxes and the HTML link I want to be different for desktop and mobile devices. Right now I have the mobile HTML files (ebookmensbeginner.html). I want to have different HTML links for the desktop (beginnermensdescription.html). How do I do this? Right now it seems I can do one or the other but not at the same time. I tried copy and pasting the code and renaming the files for the desktop version but that did not work either. Is there a way to make the html file for the desktop open up in a separate window . I have attached the code below. Right now it is for the mobile version. The page opens up and looks good as a desktop version but when I click on the images the desktop HTML file I want will not open. I want the desktop html file to open up in a separate window when they click on the box when using the desktop version. http://codepen.io/Johned22/pen/bwJrLg Thanks in advance

I think what you are looking for is called "dynamic serving," which uses the detection of the user agent to determine the device and serve different content based on the user's device.

More info can be found here:

Dynamic serving from Google.

Mobile SEO: Responsive Design vs. Separate Mobile Site vs. Dynamic Serving

Thanks for asking about this, I just learned a few things myself. Happy coding!

1 Answer

Thanks for your feedback. I have been googling dynamic serving but I cant figure out how to do it. I mean is it two different html files and if so how are they attached. If you could point me in the right direction on how to do dynamic serving that would be great.