Hugo - relative paths in page bundles
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
Sorry for the basic question, but I'm just getting started with Hugo and I can't work out how to link to an image within a page bundle.
I have the following structure in my content folder:
content/
├── about
│ └── index.md
└── post
├── post01
│ ├── img01.png
│ └── index.md
└── post02
├── img01.png
└── index.md
From my reading of the documentation on page resources, it sounds like page resources within a page bundle should have relative paths. Based on that, I thought I would be able to link to img01.png from within the post01 index.md by using the following markdown:
!(img01.png)
However, I just can't get that to work. The only way I can get it to work is to place my images into the /static folder (at the same level as /content), and then the markdown will load the image without any modification. So it seems like the relative paths aren't working the way I think they should, because any path I specify is relative to the /static folder. Can someone help me understand what's going on?
Another point of confusion is that if I rename my /content/post folder to /content/posts and then restart my local hugo server, none of my posts loads onto the front page anymore, and I can't even browse to it with the URL localhost:1313/posts (although localhost:1313/about still loads fine). What causes the homepage to automatically list the contents of /content/post but not /content/posts, and is there a particular reason for why I can't browse to localhost:1313/posts?
Thanks very much!
hugo
add a comment |
Sorry for the basic question, but I'm just getting started with Hugo and I can't work out how to link to an image within a page bundle.
I have the following structure in my content folder:
content/
├── about
│ └── index.md
└── post
├── post01
│ ├── img01.png
│ └── index.md
└── post02
├── img01.png
└── index.md
From my reading of the documentation on page resources, it sounds like page resources within a page bundle should have relative paths. Based on that, I thought I would be able to link to img01.png from within the post01 index.md by using the following markdown:
!(img01.png)
However, I just can't get that to work. The only way I can get it to work is to place my images into the /static folder (at the same level as /content), and then the markdown will load the image without any modification. So it seems like the relative paths aren't working the way I think they should, because any path I specify is relative to the /static folder. Can someone help me understand what's going on?
Another point of confusion is that if I rename my /content/post folder to /content/posts and then restart my local hugo server, none of my posts loads onto the front page anymore, and I can't even browse to it with the URL localhost:1313/posts (although localhost:1313/about still loads fine). What causes the homepage to automatically list the contents of /content/post but not /content/posts, and is there a particular reason for why I can't browse to localhost:1313/posts?
Thanks very much!
hugo
add a comment |
Sorry for the basic question, but I'm just getting started with Hugo and I can't work out how to link to an image within a page bundle.
I have the following structure in my content folder:
content/
├── about
│ └── index.md
└── post
├── post01
│ ├── img01.png
│ └── index.md
└── post02
├── img01.png
└── index.md
From my reading of the documentation on page resources, it sounds like page resources within a page bundle should have relative paths. Based on that, I thought I would be able to link to img01.png from within the post01 index.md by using the following markdown:
!(img01.png)
However, I just can't get that to work. The only way I can get it to work is to place my images into the /static folder (at the same level as /content), and then the markdown will load the image without any modification. So it seems like the relative paths aren't working the way I think they should, because any path I specify is relative to the /static folder. Can someone help me understand what's going on?
Another point of confusion is that if I rename my /content/post folder to /content/posts and then restart my local hugo server, none of my posts loads onto the front page anymore, and I can't even browse to it with the URL localhost:1313/posts (although localhost:1313/about still loads fine). What causes the homepage to automatically list the contents of /content/post but not /content/posts, and is there a particular reason for why I can't browse to localhost:1313/posts?
Thanks very much!
hugo
Sorry for the basic question, but I'm just getting started with Hugo and I can't work out how to link to an image within a page bundle.
I have the following structure in my content folder:
content/
├── about
│ └── index.md
└── post
├── post01
│ ├── img01.png
│ └── index.md
└── post02
├── img01.png
└── index.md
From my reading of the documentation on page resources, it sounds like page resources within a page bundle should have relative paths. Based on that, I thought I would be able to link to img01.png from within the post01 index.md by using the following markdown:
!(img01.png)
However, I just can't get that to work. The only way I can get it to work is to place my images into the /static folder (at the same level as /content), and then the markdown will load the image without any modification. So it seems like the relative paths aren't working the way I think they should, because any path I specify is relative to the /static folder. Can someone help me understand what's going on?
Another point of confusion is that if I rename my /content/post folder to /content/posts and then restart my local hugo server, none of my posts loads onto the front page anymore, and I can't even browse to it with the URL localhost:1313/posts (although localhost:1313/about still loads fine). What causes the homepage to automatically list the contents of /content/post but not /content/posts, and is there a particular reason for why I can't browse to localhost:1313/posts?
Thanks very much!
hugo
hugo
asked Nov 25 '18 at 3:15
Andrew RichardsonAndrew Richardson
61
61
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
There are actually three questions here.
Question 1 - page bundle images.
MarkDown is processed by the BlackFriday module which doesn't know about page bundles. You will need to use an image tag and some shortcodes to get to it. Something like:
{{ with .Resources.Match "image01.png" }}
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}">
{{end}}
See the hugo image processing page
Question 2 - post vs posts (front page)
This is actually hard to answer without a lot of information about your themes and layouts. But as a guess ...
Somewhere in the templates that generate index.hml, there will be something looks like:
{{ range .Section "post" }}
By move the contents, you changed the section name. By convention, section names are singular.
Question 3 - post vs posts (hugo server)
hugo server serves pages from memory. It is not using your file system. So, if a directory doesn't have built content, then it won't be browsable. To see exactly what hugo server will serve (with paths) then just build and look in the public/ directory.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53464336%2fhugo-relative-paths-in-page-bundles%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
There are actually three questions here.
Question 1 - page bundle images.
MarkDown is processed by the BlackFriday module which doesn't know about page bundles. You will need to use an image tag and some shortcodes to get to it. Something like:
{{ with .Resources.Match "image01.png" }}
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}">
{{end}}
See the hugo image processing page
Question 2 - post vs posts (front page)
This is actually hard to answer without a lot of information about your themes and layouts. But as a guess ...
Somewhere in the templates that generate index.hml, there will be something looks like:
{{ range .Section "post" }}
By move the contents, you changed the section name. By convention, section names are singular.
Question 3 - post vs posts (hugo server)
hugo server serves pages from memory. It is not using your file system. So, if a directory doesn't have built content, then it won't be browsable. To see exactly what hugo server will serve (with paths) then just build and look in the public/ directory.
add a comment |
There are actually three questions here.
Question 1 - page bundle images.
MarkDown is processed by the BlackFriday module which doesn't know about page bundles. You will need to use an image tag and some shortcodes to get to it. Something like:
{{ with .Resources.Match "image01.png" }}
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}">
{{end}}
See the hugo image processing page
Question 2 - post vs posts (front page)
This is actually hard to answer without a lot of information about your themes and layouts. But as a guess ...
Somewhere in the templates that generate index.hml, there will be something looks like:
{{ range .Section "post" }}
By move the contents, you changed the section name. By convention, section names are singular.
Question 3 - post vs posts (hugo server)
hugo server serves pages from memory. It is not using your file system. So, if a directory doesn't have built content, then it won't be browsable. To see exactly what hugo server will serve (with paths) then just build and look in the public/ directory.
add a comment |
There are actually three questions here.
Question 1 - page bundle images.
MarkDown is processed by the BlackFriday module which doesn't know about page bundles. You will need to use an image tag and some shortcodes to get to it. Something like:
{{ with .Resources.Match "image01.png" }}
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}">
{{end}}
See the hugo image processing page
Question 2 - post vs posts (front page)
This is actually hard to answer without a lot of information about your themes and layouts. But as a guess ...
Somewhere in the templates that generate index.hml, there will be something looks like:
{{ range .Section "post" }}
By move the contents, you changed the section name. By convention, section names are singular.
Question 3 - post vs posts (hugo server)
hugo server serves pages from memory. It is not using your file system. So, if a directory doesn't have built content, then it won't be browsable. To see exactly what hugo server will serve (with paths) then just build and look in the public/ directory.
There are actually three questions here.
Question 1 - page bundle images.
MarkDown is processed by the BlackFriday module which doesn't know about page bundles. You will need to use an image tag and some shortcodes to get to it. Something like:
{{ with .Resources.Match "image01.png" }}
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}">
{{end}}
See the hugo image processing page
Question 2 - post vs posts (front page)
This is actually hard to answer without a lot of information about your themes and layouts. But as a guess ...
Somewhere in the templates that generate index.hml, there will be something looks like:
{{ range .Section "post" }}
By move the contents, you changed the section name. By convention, section names are singular.
Question 3 - post vs posts (hugo server)
hugo server serves pages from memory. It is not using your file system. So, if a directory doesn't have built content, then it won't be browsable. To see exactly what hugo server will serve (with paths) then just build and look in the public/ directory.
answered Dec 4 '18 at 18:01
mhhollomonmhhollomon
539314
539314
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53464336%2fhugo-relative-paths-in-page-bundles%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown