I'm creating a web application using Django in IntelliJ. My HTML file wants an image but somehow my development server will not show the image at all. If I'm directly opening the HTML file and not using the server, I can see the image. I somehow feel it's an IntelliJ issue. I marked the folder as resources root and tried a bunch of things: creating an images folder at the root level and marking the folder as resources root, putting the image in same folder as HTML file; nothing works.
HTML Code:
{% extends 'base.html' %}
{% block head %}
<title>Page</title>
{% endblock %}
{% block body %}
<br><br><br>
<center><img src="1.png" height="200" width="200"></center>
{% endblock %}
Project Structure
You should also put the img file inside your static fold. Check this for detail:https://docs.djangoproject.com/en/1.11/howto/static-files/#configuring-static-files
Related
{% extends 'base.html' %}
{% block content %}
my index file starts like this but it's not extending base.html it's just showing me my index.html with what I pasted up there as text in my index.html. Im so confused..
I just tried searching solutions but i dont see what else i could change. I'm new to this stuff so only thing it could be is something with the routing but I'm just launching these without app.yaml or main.py files
I am working on a project called learning logs in the book python crash course that should be 2nd edition, chapter 18. My IDE is pycharm.
I have created a template I call index.html that inherits from a base template called base.html. Running index.html on any browser just displays the code exactly as it is and not the what the output should be. It doesn't seem to be an IDE related problem, I used the exact same code using sublime text and notepad. What am I not doing right.
base.html
<p>
➊ Learning Log
</p>
➋ {% block content %}{% endblock content %}
index.html
➊ {% extends "learning_logs/base.html" %}
➋ {% block content %}
<p>Learning Log helps you keep track of your learning, for any topic
you're
learning about.</p>
➌ {% endblock content %}
tried using different IDEs, copy pasting the code from the book.
I am using Jekyll to make a personal website. I downloaded a Bootstrap template and started changing details around. I changed the config.yml file as well as the index.html file.
When I write bundle exec jekyll serve into the command line, the server starts running and I can see a demo of what my website will look like once it is being hosted online.
The changes I made to the config.yml file persist, but those I made to the index.html file do not. When I look at the index.html file, every single change I made is reverted back to the original. It's almost like the index.html gets regenerated to a default version whenever I run the server.
The same thing happens when I try to change the default image files within the project. The new images that I placed in the img folder get deleted and the old ones that I removed get regenerated.
I googled around but found no helpful answer (deleting my browser cache does not solve the issue). Anyone know what's going on?
Edit: I should add a piece of information that may be the cause of this issue. I have two index.html files in my website. One of them is in the root folder and it simply redirects to "layout: default". The other one is in the _site folder. The latter is the one I tried to change to no avail.
Default file:
<!DOCTYPE html>
<html>
{% include head.html %}
<body id="page-top" class="index">
{% include nav.html %}
{% include header.html %}
{% include portfolio_grid.html %}
{% include about.html %}
{% if site.contact == "static" %}
{% include contact_static.html %}
{% elsif site.contact == "disqus" %}
{% include contact_disqus.html %}
{% else %}
{% include contact.html %}
{% endif %}
{% include footer.html %}
{% include modals.html %}
{% include js.html %}
</body>
</html>
Every time jekyll serve or jekyll build is executed, the default behaviour is to regenerate all your site into the _site folder.
To make changes to your index.html root file, you need to edit the one outside the _site folder (probably named /index.md or /index.html) because the content of_site` are built in each run.
As far as I gather, Jekyll parses an included page through the templating stage if and only if it finds a YAML header / front matter. Otherwise it just copies it. Is there a way to force Jekyll to parse an included file without a front matter?
The rule of thumb is that Jekyll will not parse files without front matter.
However... there is a work-around. You can create an index.html file in the _includes directory without front matter. The Liquid in this file will be interpreted by Jekyll. You can render this include anywhere using:
{% include index.html %}
This solution is perfect for rendering HTML pages within a Jekyll context (without having the front matter requirement), especially when you want to reuse them. This could be useful for rendering a preview AND showing the code in a code block on another page. The include could be written in a layout file or in an index.md file.
Note that the included filename can be a variable (https://jekyllrb.com/docs/includes/):
{% if page.my_variable %}
{% include {{ page.my_variable }} %}
{% endif %}
Also note that if you want to show Liquid examples in this code, you should use:
{% raw %} ... Liquid example ... {% endraw %}
If you want a solution work-around for your specific situation, you should share your repository and explain your use case.
I am trying include a certain markdown file that is in the root directory into another file that is in a sub-directory.
I tried many different syntaxes:
{% include_relative ../root/file %}
{% include_relative /../root/file %}
{% include_relative ./../root/file %}
{% include_relative /./../root/file %}
(and others)
Is there any way to go back to parent directories in Jekyll using Liquid Tags?
From jekyll documentation.
For example, if _posts/2014-09-03-my-file.markdown uses the
include_relative tag, the included file must be within the _posts
directory, or one of its subdirectories. You cannot include files in
other locations.