Incorporate a captivating background image onto the homepage of your Quarto website

How can I add a background image to fill the entire page on the home page only in a Quarto website?

I currently have a solution that adds the background image, but it applies it across the entire website. In this case, I want to exclude the report page from having the background image and keep it with a plain white background, navbar, and footer.

To reproduce this issue, create the following files:

_quarto.yml

project:
  type: website

website:
  title: "Sunset Sea"
  navbar:
    background: transparent
    left:
      - text: Home
        href: "index.html"
      - text: Report
        href: "report.html"
  page-footer:
    border: false
    background: transparent
    foreground: DimGray
    left: Left content
    right: Right content

format:
  html:
    theme: "styles.css"

index.qmd

---
format: html
---

# Sunset Sea

Welcome to Sunset Sea.

report.qmd

---
title: "Report"
format: html
---

## Heading 1

This is a report

styles.css

body {
  background-image: url("https://images.pexels.com/photos/189349/pexels-photo-189349.jpeg");
  background-size: cover;
  background-repeat: no-repeat;
}

Run quarto preview

Possibly, one solution is to add a specific div before or after the body div on the homepage only, and then target that div with CSS. How exactly to do this is unclear to me at the moment.

I attempted using include-before-body, but that didn't include the navbar and footer as needed.

Update the relevant section of _quarto.yml

format:
  html:
    theme: "styles.css"
    include-before-body: before.html
    include-after: after.html

before.html

<div class="splash">

after.html

</div>

Update styles.css*

.splash {
  background-image: url("https://images.pexels.com/photos/189349/pexels-photo-189349.jpeg");
  background-size: cover;
  background-repeat: no-repeat;
}

Quarto 1.2.1

Answer №1

index.qmd and Report.qmd are designed to create unique webpages. To customize the style specifically for index.html, it is recommended to define the CSS styles directly within index.qmd instead of using style.css.

index.qmd

---
format: html
---

<style>
  body {
  background-image: url("https://images.pexels.com/photos/189349/pexels-photo-189349.jpeg");
  background-size: cover;
  background-repeat: no-repeat;
}
  
</style>


# Sunset Sea

Welcome to Sunset Sea.

style.css

(please refrain from specifying background images in style.css)

/*-- scss:defaults --*/


https://i.sstatic.net/NhQj3.jpg


https://i.sstatic.net/BRVvV.png


Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

HTML - Link to enable automatic printing of the page

Assignment: Develop a hyperlink (HTML <a> tag) that triggers the printing of the webpage without the user manually pressing CTRL + P. My search for information on this topic has not yielded a definitive answer. Some sources suggest using JavaScript ...

Images in a horizontal dropdown selection menu

Currently, I have a traditional select dropdown that is data-bound with Angular. <select class="form-control" ng-model="category"> <option value="work">Work</option> <option value="home">Home</option> <option valu ...

Guide on Generating Dynamic Div Elements for Counted Value in PHP

I am receiving a dynamic div based on a count in a separate box, but I would like to have 6 fixed small divs inside the container. If the count value is 10, the additional divs should be automatically added according to the dynamic value. Below is my code ...

Update a DIV when ajax call is successful

I have a webpage with a specific heading: <div class="something"><? some php code ?></div> On this page, there is also an ajax function that performs a certain task: <script> $(document).ready(function () { $(document).ajaxSta ...

Tap the image to open it in a new window for a closer look

After retrieving data from the database, which includes images and other fields, I am trying to figure out how to make it so that when users click on an image, it opens in a new window. Below is the code snippet I have: <a target="_blank" href="#"> ...

Steps for Displaying Error Message when Search Result is Not Found in a JavaScript Table

After creating a table using HTML to display student data like name, degree, and profession, I added a search bar for users to find information on a specific student by typing the student's name. If the student is not in the table, a message "Result n ...

Unable to determine the final price, as it is unclear if a discount is applicable in Ionic

I am currently developing an Ionic Ecommerce App that is utilizing an API created in Laravel. The issue I am facing involves displaying product prices, including the actual price, discount, and final price. The problem arises when the discount is set to 0; ...

Why are you leaving a trail of timestamps in your .css files?

Within certain source codes, I have observed the following: <link rel="stylesheet" href="/css/style.css?201007071609" type="text/css" /> This prompts my question: What is the purpose behind appending 201007071609 to style.css in the code snippet ab ...

Ways to consistently display the vertical scroll bar on a mobile browser

Is there a way to always show the vertical scroll bar on mobile browsers, regardless of the page height? I've attempted using html {overflow-y: scroll;} which works well on desktop but not on mobile devices. Any suggestions or alternatives would be gr ...

Using Material-UI to add a pseudo class '::before' with component class properties

I attempted to utilize a pseudo class for the mui-app-bar but did not have success. I've researched this issue on various platforms without finding a solution. Below is how my component is currently structured: const styles = (theme: Theme) => cre ...

What is the best way to organize angularjs controllers and directives within one another?

When I structure my controllers like this: <body ng-app="app" ng-controller="ctrl"> <div ng-controller="app-get"> <app-get></app-get> </div> <div ng-controller="app-post"> <app-post">& ...

I discovered that the chips' content was in need of updating once I selected the content from the menu

I want to create a chips feature similar to Google Flights where clicking on the chips opens a menu. Currently, when I click on the chips, the menu opens up and 'Sports' is displayed as a chip. However, I want to update the 'Sports' tex ...

Can we link together two separate ngfor loops in any manner?

<div class="gl-w-100 gl-md-w-auto gl-po-rel list"> <div class="signin_wrpr gl-w-100 gl-po-rel gl-d-flex gl-fd-column gl-bg-white gl-lg-w-auto gl-md-w-auto gl-h-100 gl-md-ta-c"> <div class="head g ...

"Unusual" symbols encountered during PDF file saving

I have a PDF file titled "SA Pias - Margaça Branco.pdf" that I need to access. Currently, I am using this link: href="SA Pias - Marga%E7a Branco.pdf" Although the file opens fine in the browser, when users try to save it, they see strange characters ins ...

Can you explain the distinction between sockets and proxy passing in nginx compared to uwsgi?

My latest project setup involves flask, uwsgi, and nginx. The backend solely serves json data through an API, while the client side takes care of rendering. Typically, my Nginx configuration looks like this: My usual setup (with basic proxy passing): se ...

Unexpected behavior from HTML5 number input field

Is there a way to prevent users from entering values outside the specified max and min attributes? The constraints work when using the arrows in the input field, but not when typing directly into it. Note: I am considering utilizing angularjs for this fun ...

D3 Chart: What is the best way to insert images into a node?

Within the jsFiddle demo provided in this query, there is code displayed. I am curious about how I can assign images to each node. var graph = { "nodes":[ {"name":"1","rating":90,"id":2951}, ] } You can access my jsFiddle Demo through this ...

Strip inline styles from HTML content in django-tinymce

I am experiencing an issue with django-tinymce where it automatically adds inline styles when I save content. I would prefer to remove this behavior and only save the content in plain HTML. Can someone assist me with resolving this problem? ...

What is the best way to eliminate all borders from a select box?

Is there a way to completely remove all borders from the selectbox using either CSS or JQuery? The code snippet is as follows: <select id="doctor_ch"> <option value="1" selected>One</option> <option value="2">Two</option& ...

Scripts added to the layout page are not functioning correctly in ASP.NET MVC 5

During the development of my ASP.NET project, I encountered an issue where scripts that were placed in the "Head" section of my layout page were not accessible for use in the rendered view. The code snippet from my layout page looks like this: <!DOCT ...