Every codelab document must use the Heading 1 paragraph style to delineate the steps of the codelab. In turn, these headings will be used to automatically create a Table of Contents which shows the student exactly where they are in the codelab and lets them jump to any step.
The table of contents disappears for smaller browsers but is still available from the hamburger menu.
There is some additional metadata that is required in order to properly publish a codelab. This metadata should be added as a two-column table anywhere before the first step of the codelab. For example:
You are free to add your own metadata here if you'd like but certain key/value pairs are reserved for specific codelab publishing features. The current list of reserved metadata terms are:
Within the steps of your codelab you should use the Heading 2, Heading 3 and Heading 4 paragraph styles to organize your content. These will get translated to
<h4> tags in the codelab markup.
Also, if you wish to include some additional administrative information at the beginning of your codelab you can freely use the Heading 2, Heading 3 and Heading 4 paragraph styles and they will not show up in the codelab as long as they appear before the first Heading 1.
For the most part, it doesn't matter which fonts you use in your Google Doc draft; everything will be formatted using Roboto in the final codelab.
There are some simple ways that you can add emphasis to certain parts of the text. Bolded and italicized text will be passed through to the codelab markup as
<em> tags respectively. Also, passages of text formatted with the Courier New font will be passed through as an inline
<code> tag in the markup.
Inline images in your codelab should just work seamlessly. You can re-size them in your codelab document and that width will be applied as a max-width on the image in the codelab markup so that images are the same size relative to the text but also scale down appropriately for smaller browsers.
Youtube Videos can be embedded by doing:
Add an image in the document. The image can be a screenshot of the video for instance but it doesn't really matter since it won't be displayed but replaced by the embedded video. Add an "Alt Text" to the image by doing Cmd+Opt+Y or Right click > "Alt Text..." Put a Youtube video link in the Description field of the Alt Text. in the format https://www.youtube.com/watch?v=[video_ID] Specifying a start time is not supported at this time.
Iframes can be embedded by doing:
Add an image in the document. The image can be a screenshot of the iframe for instance but it doesn't really matter since it won't be displayed but replaced by the embedded iframe. Add an "Alt Text" to the image by doing Cmd+Opt+Y or Right click > "Alt Text..." Put a full URL in the Description field of the Alt Text. in the format https://www.domain.com/watch?foo=bar. Note that for security reasons, iframe embbedding is limited to an enumerated set of allowable iframe source URLs. Feel free to submit a PR if you'd like to augment that list or tweak your own version of the claat command.
For additional information that you would like to specially call-out in your codelab, there are two styles of info boxes:
Positive information like best practices and time saving tips should be formatted as a single-cell table with a light green 3 background.
Negative information like warnings and API usage restrictions should be formatted as a single-cell table with a light orange 3 background.
It is recommended that you keep your infoboxes clean, concise and focused on a single topic. If you have information which may be useful to know but is not a critical part of the codelab instructions, then you should link to that information from the FAQ section rather than including it as an infobox.
It's often the case that you will have command-line instructions or log messages which are formatted with a monospaced font and have pre-defined whitespace. You can add these sections to your codelab by creating a single-cell table and making sure that all the text is formatted using the Consolas font.
Code snippets with syntax highlighting can be added by creating a single-cell table and making sure that all the text is formatted using the Courier New font.
Any additional styles applied to the code will be overridden by the syntax highlighting. This means that you're free to use code highlighting Add-ons in your codelab doc but it will have no effect on how the code is highlighted in the final codelab.
It is also strongly recommended that you provide a Heading 3 header directly above your code snippet with the file name. This helps students keep track of where the code is coming from. The codelab framework also uses the file extension of the prior header as a clue for how to highlight the code.
It is also strongly recommended that you make your Heading 3 header a hyperlink to the actual file if it is available on GitHub. A GitHub icon will automatically be added to the heading in such cases.
As the author of the codelab, you have developed and tested your code. You've probably run into all sorts of common issues or misconceptions. By linking to frequently asked questions, after each step where they often occur, you will reassure the students that they have everything they need to complete the codelab and avoid having to explain everything inline in your codelab. FAQs are easy to add. All the author needs to do is provide an unordered list of hyperlinks and preface it with a Heading 3 header with the exact text: Frequently Asked Questions.
Link icons will be added automatically for stackoverflow.com, developers.google.com, developers.android.com and support.google.com. All links will be configured to open in a new tab.
You can make it really easy to get started by including direct download buttons inline in your codelab. In order to add a button to your codelab, simply add a hyperlink and make sure that it is highlighted with a dark green 1 background.
Additionally, if the link text begins with the word "Download", a file download icon will be added to the button.
Many participants are not fully committed to completing a codelab when they start it. One of the ways that we can keep them in our codelab is by giving them accurate estimates about how much additional effort is required to complete the codelab at each step.
In order to add this feature to your codelab, simply annotate each step in your codelab doc with a Duration: which uses dark grey 1 text.
That's it. The codelab framework will do everything else for you. If you forget to annotate a step with a duration, the default is 1:00. Also, if the last step of your codelab is just a congratulations page, you should set the duration of that step to 0.
Sometimes it's useful to have different versions of a codelab for different environments. For example, you might have some steps that only apply to students who take the codelab in a classroom setting while other steps only apply to people who are following the instructions at their own pace online.
The format is similar to the duration metadata. You simply specify one or more environments with an Environment: which uses dark grey 1 text. The Duration and/or Environment fields, when present, should be followed by a blank line and should be set in normal text (not in Heading 1, lest they be considered part of the step title).
If no environment metadata is specified, the default environment is "Web, Kiosk".
When previewing your codelab, you can change environments using the &env=web or &env=kiosk parameters.
It is possible for a codelab to import another doc as a step fragment. For instance, it could be a set of setup instructions shared among multiple codelabs:
[[import funny dog]]
The contents of the funny dog document will be inserted in the codelab, replacing import instruction.
The instruction syntax is:
start with [[ (two square brackets) followed by import keyword in bold followed by a link to a doc end with ]] (two square brackets) Caveat: The imported doc is limited to content within a step (hence the term "fragment"). Including multiple steps, or even the step title/heading, within the imported doc is not supported.
When a user returns to a codelab, they may be returning via a bookmark or a short-link posted online, it usually takes them to the first page of the codelab. In that case, the codelab remembers where they left off and asks them if they wish to resume where they left off. This makes it easier for the user to jump back in and gives us more accurate analytics about how long users spend on each step.
This is simply part of the framework. There is nothing that you need to do as a codelab author to enable this feature.
At the bottom of every step of the codelab there is a link for reporting bugs. This link can be configured using the Feedback Link setting in your metadata table.
NOTE: Surveys cannot be used to collect data that can individually, or in conjunction with other information from this site, help locate and identify a particular user or reveal their sensitive demographics information. Any data collected should be sufficiently anonymized and aggregated. Also, consider that the surveys can possibly send a numerical ID of the selections instead of the actual value itself. Apart from helping on the localization front, this can also help prevent from injecting obvious PII values into GA.
As we've seen in previous years, participants consume our codelabs for a wide range of reasons. In order to give us some more insight into how different people consume codelabs, we can ask them some quick multiple choice questions in the early stages of our codelab.
You can configure these short survey questions to ask whatever you think is relevant to your codelab. In order to include a survey question in your codelab, add a single-cell table with a light blue 3 background. Format your question with the Heading 4 paragraph style and provide an unordered list of choices.
The participants' answers will automatically be added as custom variables in Google Analytics which can help you understand things like:
What is the difference in completion rate between novices and experts? What is the average time spent for people who wanted to write code vs. people who just wanted to read? Is the bounce rate affected by the students' preference in IDE? Of course, we need to be mindful of our participants' time and concentration and only ask a few key questions. It is not recommended to have a survey after each step.
Having a header 2 of "What you'll learn" followed by a bullet point list creates a list of check marks.
A title of "What we've covered" has the same effect.
editor.md/ lib/ css/ scss/ tests/ fonts/ images/ plugins/ examples/ languages/ editormd.js ...
<!-- English --> <script src="../dist/js/languages/en.js"></script> <!-- 繁體中文 --> <script src="../dist/js/languages/zh-tw.js"></script>