How to add Pagination to a Hugo theme - hugo

I am using Hugo (https://gohugo.io/) with the PaperMod theme (https://github.com/adityatelange/hugo-PaperMod).
Now I created a page where I want to post pictures. But the page will be very big after some month. So thats why I want to add pagination. There should be only 5 or 10 pictures per page. At the bottom the user can click through the other pages.
How can I do this? I'm a noob in editing templates so I do not understand how to follow the docs: https://gohugo.io/templates/pagination/
Maybe someone can help and tell me what I need to edit?
Page: https://i.ibb.co/1QzyRm9/ed6ebc2c5f3b83eed63ac93cfd7b8763.png
Thank you very much...

That theme seems to already use the Pagination feature that Hugo has, so there is no need for you to change the template.
If you check the Hugo documentation on configuring pagination, you'll see that there is a setting for the item count.
# config.toml
paginate = 10
You need to update your own config.toml file with this key, and set it to whatever you need, e.g. 5.
You can try changing the value, and creating some posts there, to double-check that it's working properly.

Related

I am adding the code in weebly but it dosent show up

Issue with JSON LD CODE
To start with I am trying to use this code in weebly, buy using embed code option and then I click on the edit custom HTML and enter this code. However, after entering this nothing shows up as in the recipe is not shown on the page and a blank page is shown.
this code is picked on schema.org, for recipes.
Could anyone please help me out in what exactly went wrong. I really appreciate your assistance. FYI- I am new to this. I am trying to set up my own food website and and wanted to schema to for SEO improvement. Any other suggestions are welcome. Thanks in advance.
Please refer this link for the JSON-LD CODE. IT WILL BE AT THE END OF THE PAGE. https://schema.org/Recipe
When you add a JSON-LD block in the HTML, it doesn’t change anything visibly on the page. The script element is hidden by default in all browsers, and you typically want to keep it like that (users typically have no interest in your JSON-LD code).
To check if adding the JSON-LD worked correctly, open the page in a browser and check the source code of the page. You should see the script element with your JSON-LD.
You have to add the content (that should be visible to your users) regularly with HTML. The JSON-LD exists next to your content (duplicating the data like name, photo URL etc.), it doesn’t replace your content.

Create Landing Page in Drupal 7

In Drupal one can basically style the elements, like the search box, or the basic page etc. and then put some content in the site and the resulting page will be generated. But what if you want one specific site (e.g. the index page) to be different? E.g. have a image as a background, a different navigation styling etc.
What's the best paractice way of doing this?
Best practice is to have a different theme which you can switch to by using hook_custom_theme() where you check the current path. Also make sure that your theme to switch to is enabled:
/**
* Implements hook_custom_theme().
*/
function YOUR_MODULE_custom_theme() {
# check path with arg(0)
# return theme name to switch to
return 'different_theme_machine_name';
}
Alternatively you can also try ThemeKey doing this out of the box with an interface & allowing you the specify rules.
If you need to change only the content(body) section of your page, use Disply Suite. You can create unique look and feel layouts for your body section of each page.
If you trying to change the complete layout of one page (eg: Services), Create new Content Type 'Services'. Then create a template file for this content type, You must name this template call page--services.tpl.php. And also you can overwrite the index page layout by creating page--front.tpl.php template. Done!
What you are saying you want to change is all styling. And you know you can do a page to look drastically different with CSS... and you can do it that way depending on your chosen Drupal theme.
Now, with the Chrome Inspector (or FF inspector) look at the body tag, it probably has many classes which indicates in what page you are, what type of node (if it's a node) or if it's an admin section, or an anonymous user.
Using those specific classes you can style a frontpage, or a view, or a node, or anything, without installing more modules... with some limitations because you can't change rendered HTML this way.
Finally, don't get scared by using modules in Drupal, it's how Drupal works and it works pretty well. The thing is to install the best tools to increase your productivity, and Drupal have excellent options to change your theming and content like Display Suite (like #BaikHo suggested).
Hope that helps.
PD: Using the less module and with custom your theme you can have LESS css which is considerably faster than using only CSS, and because it's integrated with Drupal you can theme make everything even faster. Give it a try.

Scrolling website with angular: states/routing setup

I can't seem to wrap my head around a routing setup for a project I'm working on at the moment. I tried ngRoute, angular-sement-router, now trying ui-router, however I'm still struggling to understand how to use them in my scenario.
I've attached an image to illustrate the kind of a thing I want to achieve. Basically, I need to have two types of pages — one type is a multi-section scrolling page. Another one is just a plain page with text and images.
The multi-section one should scroll to a certain section according to a current route. Each section has a set of subsections. So the route like
#!/section-2/subsection-2
should make the app scroll to Section-2 (smooth scrolling is not an issue at the moment) and activate Subsection 2.
I tried using named ui-views, but then I have to have an initial state of each named ui-view on my route state. It leads to another problem. If let's say I would navigate to
#!/section-1/subsection-1
my Section 1 subsection will return to whatever is set in the initial state.
Another issue is that my setup should separate Sections 1-4 from Section 5 which is a separate page.
I hope my description makes sense. Would love to here any advice on what I can read or where can I find some useful ideas. Thanks in advance.

Drupal 7 : How to show specific block in a particular view

I want to display particular block on view page. I have added list to show specific view in a particular block as <viewpagename>, but it is not working. How can I show a particular block on a particular view page in Drupal 7?
Long time I didn't touch Drupal, however, if I remember right, after you choose a path for your view, you can add that path to the settings of the block.
so if the view is available on /view-page, add to the block setting "view-page" in the "include" section.
There is a block_views module made specifically for this reason I believe. It's in beta but works rather nicely for Drupal 7:
https://drupal.org/project/block_views
Cheers,
-cs

How to add a custom field into template.php using Zen sub theme

First time poster here, I'm a designer not skilled at all with php and I have a small issue I don't seem to be able to solve. I'm making a site in drupal 7 using a sub theme on zen.
Btw this is a great CMS, even though people say it's really more a developers CMS. I have no trouble to do what I need using views, rules, display suite etc. So a big thank you for all the developers out there making this such a good CMS. But for this apparently simple problem... no module will help me (I think) and I'm kinda stuck.
So here it is: I'd like to add a subtitle next to the title in all my pages.
So what I did was to add a custom field into the content type basic page (machine name: field_sub_title) which is a simple text field.
I uncommented the following line in my template.php
function mytheme_preprocess_page(&$variables, $hook) {
$variables['sub_title'] = t('field_sub_title');
}
Now my question is how do I load the content of my custom field into that variable?
I know i need to change the second part, but I don't have a clue as into what I need to change this.
Displaying the variable into the the page.tpl.php is something I know about so I only need help with the first part.
{EDIT}
Ok I found how to do this :)
I was looking for a solution in the wrong place. I don't need to change any thing in the template.php file.
Just needed to add this bit of code into my page.tpl.php:
<?php
print $node->field_sub_title['und'][0]['value'];
?>
So I'm posting this here for other Drupal newbies struggling with this....
Your solution may work for now, but there may be a more Drupal-y way to handle a problem like this. If you haven't noticed any problems yet, you may find one or more of the following issues down the road:
Someone who doesn't know php or Drupal theming may need to change the way this works.
If you're like me, you may forget where exactly in code this was implemented.
You may see superfluous markup and/or errors on nodes (content) that do not have this sub-title field (ie. event content not having a sub-title field while basic pages and news articles do).
When you add a field to a content type, it will automatically appear anytime content in that content type is displayed. You should be able to add the sub-title field for your page, event or whatever else you need and have it automatically appear in the markup.
You can 'manage display' of a content type to drag and drop the order for fields to appear. You could take it a step further by using a module like Display Suite to add formatting or layout per-content type.
If you feel like this isn't good enough and the markup for the subtitle must be at the same level as the page title (which is rare), at least add an if statement to make your code check to see if the variable is present before trying to print it. I'd also add a new variable and comments for code readability.
<?php
$subtitle = $node->field_sub_title['und'][0]['value'];
if($subtitle){
print $subtitle;
}
?>
Consider using field_get_items or field_view_value, or at least use the LANGUAGE_NONE constant instead of 'und'
See https://api.drupal.org/api/drupal/modules%21field%21field.module/function/field_get_items/7 and https://api.drupal.org/api/drupal/modules!field!field.module/function/field_view_value/7
This has the added benefit of reducing the number of potential security holes you create.

Resources