You can export a theme's files from Guide and work on the files offline in your preferred text editor. To avoid zipping and importing the files into Guide every time you want to preview your changes, you can preview each change locally in a web browser using the Zendesk Apps Tools (ZAT). To preview a change, you save the theme file in your desktop editor and refresh the page in the browser. Example:
ZAT is a collection of developer tools that includes Sinatra, a web server that runs locally on your computer. After starting the preview mode, the process runs in the background.
Topics covered in this article:
Setting up local theme preview
To install and use ZAT, you'll need to enable API access and set up a local development environment.
To set up local theme preview
- If not already done, enable API access in your Zendesk Support account by going to Admin > Channels > API.
- Install ZAT. See Installing and using ZAT in the Zendesk developer documentation. Then return here.
- Update ZAT by running the following command in your computer's terminal:
gem update zendesk_apps_tools
Starting local theme preview
Start the local theme preview before you start working on theme files on your computer.
To start local theme preview
- In your computer's terminal, navigate to the folder containing the exported and unzipped theme files. Example:
cd guide_themes/newlook_theme
- Run the following command:
zat theme preview
- At the prompts, enter your Zendesk subdomain, as well as the email and password you use to sign in to Zendesk Guide.
If you use single sign-on (SSO) to sign in to Guide, you can sign in using an API token. See API token in the REST API docs. When prompted by ZAT to sign in, enter {your_email}/token for your user name, where "/token" is the actual string "/token". Use the API token for your password. Example:Enter your username: jdoe@example.com/token Enter your password: e8Pvy0pvGzE8meUQxWgjIYkjr
After successfully signing in, preview mode starts and runs in the background:
- Copy the "Ready" URL in the output and paste it in a web browser, such as Chrome or Firefox. The browser must allow mixed HTTP and HTTPS content. Safari doesn't support mixed content and won't allow you to preview themes locally.
In the example, the "Ready" URL is https://z3n-example.zendesk.com/hc/admin/local_preview/start.
The URL should load the theme preview.
Previewing changes
After starting the theme preview mode, you can work on your theme files locally in your text editor. Work iteratively to develop and test your theme. For example, make some changes to your JavaScript, save the changes, then refresh the browser page to test the changes.
To preview changes
- Save the edited file in your text editor.
- Refresh the page in the browser.
When you're done, you can stop preview mode using one of the following methods:
- In the terminal session running ZAT, press Ctrl+C.
- At the top of the browser's theme preview page, click the Close preview link.
32 Comments
I have a problem, i think, with livereload and ZAT.
If a launch Zat Theme Preview my pages are unformatted and slowly, the console show this:
and some others.
I have allowed the Insecure Content on Chrome and also test with zat theme preview --no-livereload but doesn't work.
I must work with online data, on our guide, but it seems impossibile!
There is a work around for this problem?
Thanks a lot
Hi Pasquale! For an issue like this, I would recommend reaching out directly to our Advocacy team so that they can get additional information needed to assist here.
Just wanted to reach out here to see if anyone has been running into issues with the ZAT when trying to work on themes locally. For some reason it's not picking up changes to template files any more and I have to close down and rerun zat theme preview for every change.
One of my team also is getting intermittent issues where it's taking ages to fully spin up with web server which is doubly annoying given the above.
Hi, I had same problems over 1 year ago. The API for local development is just bad. I created custom solution for it because I spent 2 weeks trying to make it fully work. No chance. Server breaking connection, continuous problems with uploads etc. I created own continuous deployment scripting in Gulp. It is working and I advice to do the same. Zendesk API allowed to do it all by myself.
Trying to set this up and the first step is a show stopper, it says:
However, when I go to Admin > Channels there is no API and there is no way to add API. Did something change in how to configure this?
Hi Keith,
You can access API by going to Admin(the one that looks like the wheel icon on the left side of the screen)>Channels>API. If you are still unable to see it, you may reach out to our Customer Support so they can have a closer look into your account
I have host mapping enabled, and when I navigate to the URL generated by theme preview, I'm redirected to the specified host mapping. When I set the domain to the specified host mapping, navigating to the generated URL still redirects. What is the recommended means of previewing themes when using host mapping?
Hi Joshua,
When previewing your Help Center, you can also go to your Guide Admin>Themes>Them that you would like to preview> On the preview page, you can choose the Template and the preview role can be changed from end-user to admin
**Never-mind, it's now inexplicably working.**
Weird. I posted this message on Friday and it's missing now.
I'm working on setting up my local Zendesk Guide theme so I can make some changes. I've followed the instructions here, but when I do step 4 "Copy the "Ready" URL in the output and paste it in a browser." the help center just redirects to my main Guide page. Am I missing something?
Hello,
When I use the command
and enter all the details, the server starts, but then immediately stops with runtime error
What can I do to fix this error?
Any help appreciated, since I am new to Zendesk.
Thanks,
Arati
Is it possible you ran into issues bring the server up before this try? The error suggests that the port is taken by a process already.
You can get a list of ports using this cmd on linux:
sudo lsof -i -P -n
if the Zendesk one is open or in use you can kill the process taking the port using this.
kill -9 $(lsof -t -i:8080)
Another option is logging out and back in or a restart to free up the port.
Thank you Ben, it worked, after I restarted the system.
Next, I am running into issue like Trey above. Even if I am using the "Ready URL" I am being redirected to the main page of my guide and the URL is that of the active Zendesk site. It says it is preview mode, is that the right way like in screenshot? but the URL is not the one which I entered with preview start. Am I missing something?
Thanks,
Arati
when you visit the ready URL it always redirects back to the homepage and you get the banner you are seeing there. This should mean you are correctly in the preview and edits you make should be reflected now.
You can confirm by checking your script assets are coming from local sources.
Hi Pawel Przysucha,
Thanks for reaching out!
If you’re accessing the theme preview from a browser in which your credentials aren’t saved or you’re not logged in, the preview will still require sign-in if this is a setting in your account.
Let me know if you have any questions!
Tipene
Hi Paweł Porombka,
I just read your comment:
"The API for local development is just bad. I created custom solution for it because I spent 2 weeks trying to make it fully work. No chance. Server breaking connection, continuous problems with uploads etc. I created own continuous deployment scripting in Gulp. It is working and I advice to do the same. Zendesk API allowed to do it all by myself."
I'm really curious about how you solved those issues. Would you maybe write a community post that explains how you created your custom solution? I hope so! Thanks :)
Or, it would be great if we could get guidance from Zendesk on those issues with ZAT theme preview. It's really slowing down our development :/
Hi Gizem! Could you let me know what filesystem you're using? We use the `listen` gem for ZAT, which does have some limitations related to the fs that it's being run on. There is an open PR on the ZAF repo to force polling, which could potentially resolve this, but with it being in maintenance mode right now, it's difficult to get traction on moving that forward. I'll see what I can do though!
Hi Greg,
Thanks for taking a look at this! My filesystem seems to be "APFS (Encrypted)".
I hope you can get the PR moving and that can fix the issues with previewing! 🤞🙏
Hello folks,
I am using Okta to sign in, how to get my password for zat theme preview?
I'm in the same situation, you can generate an API token, and use that with /token after your email to generate the preview, Rajan.
https://support.zendesk.com/hc/en-us/articles/4408889192858-Generating-a-new-API-token
Since ZAT is no longer supported, this article could use an overhaul.
Can anyone help me with this error?
Hi Brittany! Typically that's an indication that your credentials were incorrect. If you are using an API token, did you append "/token" to your email address? If not, do you have any more information that you can share with us here so we can best assist?
Greg Katechis - I got it working, that said - the preview tool leaves a lot to be desired and functions very poorly.
Hi CJ Johnson,
Thanks for reaching out. I saw your comment:
This isn't quite accurate. Although ZAT is in maintenance mode, it's still supported. While we now encourage developers to use ZCLI for app development, ZCLI doesn't currently support theme previews [related docs].
That said, I'll give this article a review for any other issues. Thanks again. We appreciate the feedback.
Hello Team
Since ZAT is in maintenance mode and has bugs for previewing the theme locally. What is the other option for local theme preview as ZCLI doesn't support it?
cc: James Rodewig, CJ Johnson, Greg Katechis
Having issues with ZAT THEME PREVIEW suddenly, for a week now. Using standard port only. Read about the updates and related problems afterwards, but based on the updates, there should not be any issues anymore with standard port. *.js and *.css files fail to load due failed preflight request, which is unexpected.
Can someone confirm that your environments are working fine with zat theme preview?
If so, I need figure out, what it wrong with my own environment.
It was something to do with default "ip address". By default theme preview / sinatra was listening on 0.0.0.0:4567 as follows, and it seemed to fail after returning just a couple of files of the first page load. After that just empty responses after long delays, which I saw in browser network panel as failed preflight requests.
I have no idea whether this had changed at some point, but as installed latest Ubuntu on Windows again and the rest tools according to Zendesk instructions, that that was the default address again, and with the same problem.
This fixed it for me finally - when starting preview, binding it to localhost ip address:
I do not know, if this was specific to my environment, but at least you can try this, if run into similar problems.
I can't even get ZAT working on Ubuntu 22 following:
https://developer.zendesk.com/documentation/apps/zendesk-app-tools-zat/installing-and-using-zat/
Error: "can't find header files for ruby at /usr/lib/ruby/include/ruby.h
You might have to install separate package for the ruby development
environment, ruby-dev or ruby-devel for example."
Except those aren't even valid gems anymore. Kinda stopped in my tracks here.
Please sign in to leave a comment.