Learn how to successfully export artboards and files for web as SVG and PNG in our comprehensive Sketch tutorial, which also includes detailed instructions on exporting into folders.
This exercise is excerpted from Noble Desktop’s past web design training materials and is compatible with Sketch updates through 2021. Noble Desktop now teaches Figma as the primary tool for web and UX & UI design. To learn current skills in web design, check out our Figma Bootcamp and graphic design classes in NYC and live online.
Note: These materials are provided to give prospective students a sense of how we structure our class exercises and supplementary materials. During the course, you will get access to the accompanying class files, live instructor demonstrations, and hands-on instruction.
Topics covered in this Sketch tutorial:
Exporting artboards, Exporting for web as SVG & PNG, Exporting into folders
Exercise Preview
Exercise Overview
In this exercise, you’ll learn how to export SVG and PNG files for use in webpages.
Exporting Artboards
Before we export individual graphics, we often need to send the entire page design to a client (or developer). For that purpose we can export the entire artboard.
- In Sketch, go to File > Open Local Document.
- Navigate into Desktop > Class Files > Sketch Class > iTastify and double–click on iTastify Ready for Export SVG & PNG.sketch to open it.
- In the Sidebar, click on the Desktop artboard to select it.
- In the Inspector, click Make Exportable. If you don’t see it, scroll down to the bottom!
-
Make sure the export Format is set to PNG.
PNG is a high quality format, so a client or developer will see the full quality of the design. If the PNG is too large to easily share, JPEG can be a good alternative.
-
In the Inspector, notice that some sections of the preview have a transparent background, indicated by the white and gray checkerboard:
- In the Inspector, check on Background color. (Include in Export should also be checked.)
- In the preview, notice that the transparent background has now changed to white, which is how our design is supposed to look.
-
Go to File > Export.
NOTE: The name of the artboard will be used for the name of the file. The artboard is called Desktop, so the file will be named Desktop.png.
- In the dialog that appears, click Export.
- Make sure Save for web is checked. This sets the appropriate color space and doesn’t include any metadata that’s unnecessary for the web.
- Navigate into Desktop > Class Files > Sketch Class > iTastify > assets-for-developer.
-
Click Save.
The PNG file was created, which you could send to your client or developer.
Exporting for Web as SVG
Let’s export some of the graphics within the page, so we can send them to a web developer.
- Click on a blank area of the canvas to deselect the artboard.
- Select the iTastify logo on the top left of the artboard.
-
The layer’s name will be used as the file name. In the Sidebar, notice the layer is named iTastify Logo.
In web graphics we can’t use spaces in filenames (we use an underscore or a dash instead). It’s also best to keep it lowercase, so we’ll have to rename the layer.
- With the logo still selected, hit Cmd–R to rename the layer.
- Type in itastify-logo and hit Return to apply it.
- In the Inspector, click Make Exportable.
-
This is a vector graphic, so the best web format is SVG (Scalable Vector Graphics). Set the Format to SVG.
Whenever possible, it’s better to use SVG (Scalable Vector Graphics) instead of PNG or JPEG (which are pixel-based). With SVG you get a single graphic file that looks great on hi-res and low-res screens, and it can be resized in the webpage with no loss of quality! It will always look crisp and clean.
- Let’s make a few other things exportable. On the artboard, select the black App Store download button.
- In the Sidebar, notice that the layer name is not ideal for web. Hit Cmd–R.
- Type in download-app-button and hit Return to apply it.
- On the artboard, select the iTastify app icon (the red rounded rectangle icon).
- In the Sidebar, notice it’s appropriately named.
- We want to make both icons exportable. With the iTastify app icon still selected, Shift–click on the App Store download button so both are selected.
- In the Inspector, click Make Exportable to make them both exportable.
- Set the Format to SVG.
- Click on a blank area of the canvas to deselect both icons.
- Go to File > Export.
- In the dialog that appears we can choose what we want to export. We want to export everything, so check Export All.
- Click Export.
- Make sure you’re still in the assets-for-developer folder. If not, navigate into Desktop > Class Files > Sketch Class > iTastify > assets-for-developer.
- Click Export once more.
- Hide or minimize Sketch, so you can see the Desktop (Finder).
- Navigate to Class Files > Sketch Class > iTastify > assets-for-developer.
- You should see four files (and two folders that we created). To preview the files, select a file and hit Spacebar.
-
While the preview is open, switch between files using the Arrow keys.
NOTE: When previewing SVG files in the Finder, you may notice extra whitespace. That’s only in the preview and is not actually in the SVG file.
- To close the preview, hit the Spacebar again.
We’ll be coming back to this folder again in this exercise, so leave this Finder window open and switch back to Sketch.
Exporting for Web as PNG
The photo of the hand holding an iPhone requires a transparent background, so it can be composited onto the background pattern in the final webpage. JPEG is best for compressing photos, but it doesn’t support transparency. We’ll have to make this a PNG.
- Hover over the photo of the hand holding the iPhone, but do not click.
- Notice there is a blue outline surrounding the pattern filled gray rectangle, indicating it would be selected if we click. We only want to select the photo though.
- Hold Cmd and hover over the photo of the hand.
- Now only the hand part should have the blue outline, so click to select it!
- In the Sidebar, notice the iphone-hand-mockup layer is selected. That name is good for exporting, so we don’t need to change it.
- In the Inspector, click Make Exportable.
- Set the Format to PNG.
- PNG is a pixel-based format, so we need to create two sizes. One will be for low-res screens (called 1x) and one will be for hi-res or Retina screens (called 2x). In the Inspector’s Export section, to the far right of Presets click the plus button to add a new export size.
- Notice the new export format is sized as 2x (200%), and the filename will automatically get an @2x added at the end. That’s perfect.
Exporting into Folders
- Scroll down to see the three icons below the iTastify Helps You Remember heading.
-
Drag a selection box over the three icons:
-
In the Sidebar, notice the three highlighted layer groups start with feature- before their individual names.
This would be fine for organizing in an alphabetical list of files, but we want a folder instead. If you name layers using the folderName/fileName convention, Sketch will create folders when exporting!
- Let’s rename them to put all of these icons into a feature folder. Double–click feature-companions and rename to: feature/companions
-
For the other two feature layer names, change the - to a / so you end up with:
- feature/photos
- feature/notes
- Make sure all three icons are selected before moving on.
- In the Inspector, click Make Exportable.
-
Set the Format to SVG.
As a reminder, with SVG, we don’t need to worry about 1x vs 2x. Web browsers will render the vector at full screen resolution.
- Click on a blank area of the canvas to deselect.
- Go to File > Export.
- In the dialog that appears, check Export All.
- Click Export.
- Make sure you’re still in the assets-for-developer folder. If not, navigate into Desktop > Class Files > Sketch Class > iTastify > assets-for-developer.
- Click Export.
- Switch back to the Finder (your Desktop).
- You should still have a window open for the assets-for-developer folder and the new assets have been added here. Notice the new feature folder was created and it contains the three SVG icons.
Feel free to preview any of the assets if you wish.
Optional Challenge: More Practice Exporting
Export the four rating icons as SVG (just the circle icons, not the text). Export just them into a rate folder (so you’ll have to rename the layers).
Reducing the Size of PNGs Exported from Sketch
Sketch exports as PNG-24 (with transparency). A PNG-24 contains millions of colors, and the file size can be quite large. When you don’t need that many colors, there are a couple things you can do to reduce the file size:
- You can use a free app called ImageAlpha to reduce the PNG-24 down to a PNG-8. It will maintain the transparency, but uses fewer colors so the file size will be much smaller. For more info, read the Image Optimization Tools reference near the end of this workbook.
- You can also use Photoshop’s File > Export > Export As to export as PNG-8 (requires Photoshop CC 2015 or later).