From the course: Create Your Own Data Blog with Quarto and Python

Building and previewing your data blog

- [Instructor] You'll want to be able to preview your blog as you write your blog posts. So let's see how to do that in the 03_02B code space. You'll need to go to the terminal and you'll need to run Quarto preview. So I hit enter. It takes a couple of moments to preview the entire blog. And there we go. We can see that the preview is finished, it's available for us. And so what I'm gonna do is I'm going to select that URL and take it over to my web browser. Great, we can see our data blog. All of this boilerplate content comes in a Quarto create project command that we used in the previous lesson. I want to prove to you this is live previewing by updating the homepage of the data blog. So let's head back over to the code space, and I want you to guess which of these files updates or builds the homepage. It's the index.qmd file. Let's open up that file. Let's scroll to the bottom and let's add hello world. And I also want to add some Python code to demonstrate to you that you can use Python anywhere you like in your data blog, not just in blog posts. So let's open up the command palette and let's go to insert code cell. You can see there's a keyboard shortcut for that command, and let's type in here two to the power of eight, and let's add one to it as well. And you can see that as we've been typing, the preview updates. So if we head over to the web browser, we can see that my previewed webpage now has that code in it and hello world as well. But this could be really annoying if every single time you type, your Quarto data blog is being rerun because your code could take a long time to run or you might write code that doesn't work yet. So for instance, let's head back to the code space. We might divide this by foobar, which is a variable that we haven't defined yet, but because live previewing is connected to the auto save feature, we're not going to get an updated preview, but our Python kernel is going to be busy. So I recommend that when you're working with a Quarto data blog, you disable auto save. So let's do that. We'll go to file, we'll uncheck auto save, and now we can update our code. And the preview doesn't update unless we hit save. When we do hit save, we can see that our preview updates and if we head back over to the web browser, we can see that our live previewing is working. Great. Now what you want to do is add your first post to your data blog, which I'll show you in the very next lesson.

Contents