Skip to content

Conversation

@mcanouil
Copy link
Contributor

@mcanouil mcanouil commented Oct 18, 2024

This pull request adds a tip to the documentation about using absolute paths in the include shortcode. The tip explains that using absolute paths ensures that links and images in included files resolve correctly regardless of where the file is included via the shortcode.

Motivation: several users were bitten by this. The explicit tip might help avoid the issue.

@cscheid
Copy link
Collaborator

cscheid commented Oct 18, 2024

I'd prefer if we didn't nest callouts.

@mcanouil
Copy link
Contributor Author

mcanouil commented Oct 18, 2024

I noticed an issue and was filling it before reverting this^^

@mcanouil mcanouil changed the title docs: add tip about absolute path in include shortcode note docs: add tip about absolute path in include shortcode important callout Oct 18, 2024
Include shortcodes are equivalent to copying and pasting the text from the included file into the main file. This means that relative references (links, images, etc.) inside the included file resolve based on the directory of the main file not the included file.
Include shortcodes are equivalent to copying and pasting the text from the included file into the main file.
This means that relative references (links, images, etc.) inside the included file resolve based on the directory of the main file not the included file.
Use absolute (to the project root) paths for links and images in included files to ensure they resolve correctly, *e.g.*, `{{< include /path/to/file.qmd >}}`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the example. Shouldn't it be an example of a link or image, not an include?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, both were the cause of issues to users. I've added an image example as well.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean when using {{< include >}} inside an included file? In which case, it might be clearer to inlcude that in the examples of references :

This means that relative references (links, images, other includes, etc.) inside the included file resolve based on the directory of the main file not the included file.  
Use absolute (to the project root) paths for links, images or other includes, in included files to ensure they resolve correctly, *e.g.*, ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cwickham
Copy link
Collaborator

/deploy-preview

@github-actions
Copy link
Contributor

🚀 Deployed on https://deploy-preview-1392.quarto.org

@cwickham cwickham merged commit a072df8 into quarto-dev:main Oct 22, 2024
3 checks passed
@cwickham
Copy link
Collaborator

Thanks @mcanouil !

@github-actions
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants